• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / py-slang / 23248291284

18 Mar 2026 01:56PM UTC coverage: 34.925% (+0.09%) from 34.836%
23248291284

Pull #99

github

web-flow
Merge 70a0573d1 into d2ff517a4
Pull Request #99: Package improvements follow up

266 of 1054 branches covered (25.24%)

Branch coverage included in aggregate %.

7 of 107 new or added lines in 7 files covered. (6.54%)

3 existing lines in 1 file now uncovered.

1109 of 2883 relevant lines covered (38.47%)

84.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.27
/src/parser/errors.ts
1
import { createErrorIndicator, getFullLine, MAGIC_OFFSET } from "../errors";
2✔
2
import { Token } from "../tokenizer";
3

4
export namespace ParserErrors {
2✔
5
  export class BaseParserError extends SyntaxError {
2✔
6
    line: number;
7
    col: number;
8

9
    constructor(message: string, line: number, col: number) {
10
      super(`SyntaxError at line ${line}
×
11
                   ${message}`);
12
      this.line = line;
×
13
      this.col = col;
×
14
      this.name = "BaseParserError";
×
15
    }
16
  }
17
  export class ExpectedTokenError extends BaseParserError {
2✔
18
    constructor(source: string, current: Token, expected: string) {
NEW
19
      const { lineIndex, fullLine } = getFullLine(
×
20
        source,
21
        current.indexInSource - current.lexeme.length,
22
      );
23
      let hint = `^ ${expected}. Found '${current.lexeme}'.`;
×
24
      hint = hint.padStart(hint.length + current.col - MAGIC_OFFSET, " ");
×
NEW
25
      super("\n" + fullLine + "\n" + hint, lineIndex, current.col);
×
26
      this.name = "ExpectedTokenError";
×
27
    }
28
  }
29
  export class NoElseBlockError extends BaseParserError {
2✔
30
    constructor(source: string, current: Token) {
NEW
31
      const { lineIndex, fullLine } = getFullLine(source, current.indexInSource);
×
32
      let hint = `^ Expected else block after this if block.`;
×
33
      hint = hint.padStart(hint.length + current.col - MAGIC_OFFSET, " ");
×
NEW
34
      super("\n" + fullLine + "\n" + hint, lineIndex, current.col);
×
35
      this.name = "NoElseBlockError";
×
36
    }
37
  }
38
  export class GenericUnexpectedSyntaxError extends BaseParserError {
2✔
39
    constructor(line: number, col: number, source: string, start: number) {
NEW
40
      const { lineIndex, fullLine } = getFullLine(source, start);
×
41
      const hint = ` Detected invalid syntax.`;
×
42
      const indicator = createErrorIndicator(fullLine, -1);
×
NEW
43
      super("\n" + fullLine + "\n" + indicator + hint, lineIndex, col);
×
44
      this.name = "GenericUnexpectedSyntaxError";
×
45
    }
46
  }
47
  export class InvalidAssignmentError extends BaseParserError {
2✔
48
    constructor(source: string, current: Token) {
NEW
49
      const { lineIndex, fullLine } = getFullLine(source, current.indexInSource);
×
50
      let hint = `^ Invalid assignment target.`;
×
51
      hint = hint.padStart(hint.length + current.col - MAGIC_OFFSET, " ");
×
NEW
52
      super("\n" + fullLine + "\n" + hint, lineIndex, current.col);
×
53
      this.name = "InvalidAssignmentError";
×
54
    }
55
  }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc