Skip to content

Commit

Permalink
Remove { ?, ?, true }-style notation. Closes #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
robsimmons committed Nov 19, 2023
1 parent ab2d14a commit 3c209b7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/engine/choiceengine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ test('Overlapping non-exhaustive and exhaustive choices', () => {
a.
b.
c is { a, b, d, e } :- a.
c is { a, b, ?, c } :- a.
c is { a, b, c? } :- a.
c is { a, c, d, e } :- b.
c is { c? }.
c is { a, ? }.
c is { ?, f }.
c is { a? }.
c is { f? }.
`);
expect(solutionsToStrings(solutions)).toEqual(['a, b, c is a', 'a, b, c is d', 'a, b, c is e']);
});
Expand Down
2 changes: 1 addition & 1 deletion src/langauge/dusa-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('Parser and pretty pretter idempotence', () => {
expectRoundTripToParse('a is { ? }.');
expectRoundTripToParse('a is { b? }.');
expectRoundTripToParse('a is { b, c }.');
expectRoundTripToParse('a is { b, c, ? }.');
expectRoundTripToParse('a is { b, c? }.');
expectRoundTripToParse('a is { b, c d }.');
expectRoundTripToParse('a is { b, c ((d e)) }.', 'a is { b, c (d e) }.');
});
6 changes: 1 addition & 5 deletions src/langauge/dusa-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ export function parseHeadValue(t: Istream<Token>): {
}
while ((tok = chomp(t, '}')) === null) {
if (chomp(t, ',')) {
if (chomp(t, '?')) {
exhaustive = false;
} else {
values.push(forceFullTerm(t));
}
values.push(forceFullTerm(t));
} else {
force(t, '?');
end = force(t, '}').loc.end;
Expand Down
2 changes: 1 addition & 1 deletion src/langauge/syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function headToString(head: Conclusion) {
} else if (head.values.length !== 1 || !head.exhaustive) {
return `${head.name}${args} is { ${head.values
.map((term) => termToString(term, false))
.join(', ')}${head.exhaustive ? '' : head.values.length < 2 ? '?' : ', ?'} }`;
.join(', ')}${head.exhaustive ? '' : '?'} }`;
} else if (head.values[0].type === 'triv') {
return `${head.name}${args}`;
} else {
Expand Down

0 comments on commit 3c209b7

Please sign in to comment.