antlr4-runtime
Version:
JavaScript runtime for ANTLR4
44 lines (38 loc) • 1.18 kB
JavaScript
/* 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 {default as LexerActionType } from "../atn/LexerActionType.js";
import LexerAction from "./LexerAction.js";
/**
* Implements the {@code mode} lexer action by calling {@link Lexer//mode} with
* the assigned mode
*/
export default class LexerModeAction extends LexerAction {
constructor(mode) {
super(LexerActionType.MODE);
this.mode = mode;
}
/**
* <p>This action is implemented by calling {@link Lexer//mode} with the
* value provided by {@link //getMode}.</p>
*/
execute(lexer) {
lexer.mode(this.mode);
}
updateHashCode(hash) {
hash.update(this.actionType, this.mode);
}
equals(other) {
if (this === other) {
return true;
} else if (! (other instanceof LexerModeAction)) {
return false;
} else {
return this.mode === other.mode;
}
}
toString() {
return "mode(" + this.mode + ")";
}
}