-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathTraceListener.js
More file actions
24 lines (20 loc) · 861 Bytes
/
TraceListener.js
File metadata and controls
24 lines (20 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved.
* Use is of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
import ParseTreeListener from "./tree/ParseTreeListener.js";
export default class TraceListener extends ParseTreeListener {
constructor(parser) {
super();
this.parser = parser;
}
enterEveryRule(ctx) {
console.log("enter " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text);
}
visitTerminal(node) {
console.log("consume " + node.symbol + " rule " + this.parser.ruleNames[this.parser._ctx.ruleIndex]);
}
exitEveryRule(ctx) {
console.log("exit " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text);
}
}