Skip to content

Commit 433f3da

Browse files
committed
adding some documentation and fixing a descending for loop condition
1 parent 3723c7c commit 433f3da

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/slang-utils/create-parser.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ const milestoneVersions = [
4343
'0.8.22',
4444
'0.8.27',
4545
'0.8.29'
46-
].map((milestone) => maxSatisfying(supportedVersions, `<${milestone}`)!);
46+
].map(
47+
// Since we are aiming to find the highest compatible Language version, we
48+
// define a milestone as the highest possible supported version that is
49+
// smaller than the original milestone taken from the documentation.
50+
// This has an extra cost in execution time and the actual list could be
51+
// hardcoded, but the calculation is done only once and it's easier to
52+
// maintain.
53+
(milestone) => maxSatisfying(supportedVersions, `<${milestone}`)!
54+
);
4755

4856
export function createParser(
4957
text: string,
@@ -71,7 +79,7 @@ export function createParser(
7179
inferredRanges.includes(milestone)
7280
);
7381

74-
for (let i = inferredMilestones.length - 1; i > 0; i -= 1) {
82+
for (let i = inferredMilestones.length - 1; i >= 0; i -= 1) {
7583
const version = inferredMilestones[i];
7684
result.parser = Parser.create(version);
7785
result.parseOutput = result.parser.parseNonterminal(

0 commit comments

Comments
 (0)