Skip to content

Commit 439539d

Browse files
authored
Merge pull request #446 from codefori/fix/comments_breakage_443
Fix comment parsing issue in the compiler
2 parents c116576 + 49d9213 commit 439539d

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

language/parser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ export default class Parser {
624624
lineIsFree = false;
625625
lineNumber += 1;
626626

627-
if (baseLine.startsWith(`**`)) {
627+
if (baseLine.startsWith(`**`) && baseLine[2] !== `*`) {
628628
// Usually is **FREE
629629
if (lineNumber === 0) continue;
630630
// After compile time data, we're done
@@ -1506,8 +1506,7 @@ export default class Parser {
15061506
}
15071507

15081508
switch (cSpec.opcode && cSpec.opcode.value) {
1509-
case `BEGSR`:
1510-
1509+
case `BEGSR`:
15111510
if (cSpec.factor1 && !scope.find(cSpec.factor1.value, `subroutine`)) {
15121511
currentItem = new Declaration(`subroutine`);
15131512
currentItem.name = cSpec.factor1.value;

tests/suite/fixed.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,4 +1425,29 @@ test('incorrect range on prototypes and procedures (#412)', async () => {
14251425
expect(prRange.start).to.deep.equal(prRange.end-1);
14261426
expect(procRange.start).toBeGreaterThan(prRange.end);
14271427
expect(procRange.end).toBeGreaterThan(procRange.start);
1428+
});
1429+
1430+
test('missing subroutines #443', async () => {
1431+
const lines = [
1432+
` C PROCRC BEGSR`,
1433+
` C*`,
1434+
` C ENDSR`,
1435+
` C**************************`,
1436+
` C ADDSUB BEGSR`,
1437+
` C MOVE #4XDSP XHXDSP O/G LINE`,
1438+
`******* USE CLASS CODE FROM OVERRIDDEN CLASS!`,
1439+
` C LDACL IFEQ 'B'`,
1440+
` C ENDIF`,
1441+
` C*`,
1442+
` C ENDSR`,
1443+
].join(`\n`);
1444+
1445+
const cache = await parser.getDocs(uri, lines, {withIncludes: true, ignoreCache: true});
1446+
1447+
expect(cache).toBeDefined();
1448+
1449+
const subroutines = cache.subroutines;
1450+
expect(subroutines.length).toBe(2);
1451+
expect(subroutines[0].name).toBe('PROCRC');
1452+
expect(subroutines[1].name).toBe('ADDSUB');
14281453
});

0 commit comments

Comments
 (0)