Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 5445x 5445x 1761x 1761x 1x 1x 30x 30x | /**
* Assignment Site Listener
*
* Hands every assignment the grammar spells to a callback as one shape: a
* statement (`x +<- 1;`), a for-loop initializer (`for (x +<- 1; ...)`) and a
* for-loop update (`for (...; ...; x +<- 1)`).
*
* Which grammar rules are assignments is a single fact about the grammar. An
* analyzer that hooked the statement alone read the other two as absent, so
* `for (...; ...; i +<- flag)` compiled while `i +<- flag;` was E0807 (#1668).
*/
import { CNextListener } from "../../PARSE/2-Parse/grammar/CNextListener";
import * as Parser from "../../PARSE/2-Parse/grammar/CNextParser";
import type TAssignmentSite from "./types/TAssignmentSite";
class AssignmentSiteListener extends CNextListener {
constructor(private readonly onAssignment: (site: TAssignmentSite) => void) {
super();
}
override enterAssignmentStatement = (
ctx: Parser.AssignmentStatementContext,
): void => {
this.onAssignment(ctx);
};
override enterForAssignment = (ctx: Parser.ForAssignmentContext): void => {
this.onAssignment(ctx);
};
override enterForUpdate = (ctx: Parser.ForUpdateContext): void => {
this.onAssignment(ctx);
};
}
export default AssignmentSiteListener;
|