Skip to content

Commit

Permalink
fix: support parsing debugger statements
Browse files Browse the repository at this point in the history
  • Loading branch information
eventualbuddha committed May 9, 2021
1 parent f99f769 commit df9ae74
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mappers/mapLiteral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Bool,
Break,
Continue,
Debugger,
Float,
Identifier,
Int,
Expand Down Expand Up @@ -87,6 +88,8 @@ export default function mapLiteral(context: ParseContext, node: Literal): Node {
return new Break(line, column, start, end, raw);
} else if (node.value === 'continue') {
return new Continue(line, column, start, end, raw);
} else if (node.value === 'debugger') {
return new Debugger(line, column, start, end, raw);
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,22 @@ export class Continue extends Node {
}
}

export class Debugger extends Node {
constructor(
line: number,
column: number,
start: number,
end: number,
raw: string
) {
super('Debugger', line, column, start, end, raw);
}

getChildNames(): Array<keyof this & string> {
return [];
}
}

export class Spread extends Node {
constructor(
line: number,
Expand Down
60 changes: 60 additions & 0 deletions test/__snapshots__/examples.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5983,6 +5983,36 @@ Program {
}
`;

exports[`CS1: debugger 1`] = `
Program {
"body": Block {
"column": 1,
"end": 8,
"inline": false,
"line": 1,
"raw": "debugger",
"start": 0,
"statements": Array [
Debugger {
"column": 1,
"end": 8,
"line": 1,
"raw": "debugger",
"start": 0,
"type": "Debugger",
},
],
"type": "Block",
},
"column": 1,
"end": 8,
"line": 1,
"raw": "debugger",
"start": 0,
"type": "Program",
}
`;

exports[`CS1: delete 1`] = `
Program {
"body": Block {
Expand Down Expand Up @@ -26808,6 +26838,36 @@ Program {
}
`;

exports[`CS2: debugger 1`] = `
Program {
"body": Block {
"column": 1,
"end": 8,
"inline": false,
"line": 1,
"raw": "debugger",
"start": 0,
"statements": Array [
Debugger {
"column": 1,
"end": 8,
"line": 1,
"raw": "debugger",
"start": 0,
"type": "Debugger",
},
],
"type": "Block",
},
"column": 1,
"end": 8,
"line": 1,
"raw": "debugger",
"start": 0,
"type": "Program",
}
`;

exports[`CS2: delete 1`] = `
Program {
"body": Block {
Expand Down
1 change: 1 addition & 0 deletions test/examples/debugger.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debugger

0 comments on commit df9ae74

Please sign in to comment.