Skip to content

Commit 4d57790

Browse files
committed
Allow multiple chained applications
1 parent b11de8d commit 4d57790

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/end-to-end.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ testCases(endToEnd, code => code)('end-to-end tests', [
6161
['{ (a: A) (b: B) }', either.makeRight({ a: 'A', b: 'B' })],
6262
['({ ((a): :(b)) ((b): B) })', either.makeRight({ a: 'B', b: 'B' })],
6363
['{ (a: :(")")), (")": (B)) }', either.makeRight({ a: 'B', ')': 'B' })],
64+
[':match({ a: A })({ tag: a, value: {} })', either.makeRight('A')],
6465
[
6566
`{
6667
"static data":"blah blah blah"

src/language/parsing/molecule.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,23 @@ const sugaredFunction: Parser<PartialMolecule> =
8787
const sugaredApply: Parser<PartialMolecule> = parser.map(
8888
parser.sequence([
8989
parser.oneOf([sugaredLookup, parser.lazy(() => sugaredFunction)]),
90-
parser.literal('('),
91-
parser.lazy(() => propertyValue),
92-
parser.literal(')'),
90+
parser.oneOrMore(
91+
parser.sequence([
92+
parser.literal('('),
93+
parser.lazy(() => propertyValue),
94+
parser.literal(')'),
95+
]),
96+
),
9397
]),
94-
([f, _, argument]) => ({
95-
0: '@apply',
96-
function: f,
97-
argument,
98-
}),
98+
([f, multipleArguments]) =>
99+
multipleArguments.reduce<PartialMolecule>(
100+
(expression, [_1, argument, _2]) => ({
101+
0: '@apply',
102+
function: expression,
103+
argument,
104+
}),
105+
f,
106+
),
99107
)
100108

101109
const propertyKey = atomParser

0 commit comments

Comments
 (0)