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

source-academy / js-slang / 23995741899

05 Apr 2026 06:14AM UTC coverage: 77.093% (+0.002%) from 77.091%
23995741899

push

github

web-flow
Upgrade to TypeScript 6 and Prettier improvements (#1936)

* Upgrade TypeScript to v6

* Fix import source

* Fix tsconfig

* Fix preexisting type errors

* Remove scm-slang

* Bump node types

* Fix tsconfig

* Fix node types specifier

* Enable trailing commas

* Enable semicolons

* Check and commit files with changed line numbers

* Update Yarn to 4.13.0

* Remove unneeded sicp package deps

3112 of 4282 branches covered (72.68%)

Branch coverage included in aggregate %.

3761 of 5218 new or added lines in 152 files covered. (72.08%)

26 existing lines in 9 files now uncovered.

7136 of 9011 relevant lines covered (79.19%)

175254.05 hits per line

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

85.0
/src/parser/python/index.ts
1
import type { Program } from 'estree';
2

3
import { Chapter } from '../../langs';
4
import { parsePythonToEstreeAst } from '../../py-slang/src';
5
import type { Context } from '../../types';
6
import { FatalSyntaxError } from '../errors';
7
import type { AcornOptions, Parser } from '../types';
8
import { positionToSourceLocation } from '../utils';
9

10
export class PythonParser implements Parser<AcornOptions> {
11
  private chapter: Chapter;
12
  constructor(chapter: Chapter) {
13
    this.chapter = chapter;
68✔
14
  }
15
  parse(
16
    programStr: string,
17
    context: Context,
18
    options?: Partial<AcornOptions>,
19
    throwOnError?: boolean,
20
  ): Program | null {
21
    try {
72✔
22
      // parse the Python code
23
      const chapterNum = (() => {
72✔
24
        switch (this.chapter) {
72!
25
          case Chapter.PYTHON_1:
26
            return 1;
72✔
27
          // Future additions:
28
          //   case Chapter.PYTHON_2:
29
          //     return 2
30
          //   case Chapter.PYTHON_3:
31
          //     return 3
32
          //   case Chapter.PYTHON_4:
33
          //     return 4
34
          default:
NEW
35
            throw new Error('Unreachable path');
×
36
        }
37
      })();
38
      return parsePythonToEstreeAst(programStr, chapterNum, true);
72✔
39
    } catch (error) {
40
      if (error instanceof SyntaxError) {
3!
41
        error = new FatalSyntaxError(
3✔
42
          positionToSourceLocation((error as any).loc),
43
          error.toString(),
44
        );
45
      }
46

47
      if (throwOnError) throw error;
3✔
48
      context.errors.push(error);
1✔
49
    }
50
    return null;
1✔
51
  }
52

53
  validate(_ast: Program, _context: Context, _throwOnError: boolean): boolean {
54
    return true;
68✔
55
  }
56

57
  toString(): string {
58
    return `PythonParser{chapter: ${this.chapter}}`;
1✔
59
  }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc