UNPKG

antlr4-runtime

Version:

JavaScript runtime for ANTLR4

44 lines (38 loc) 1.21 kB
/* 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 pushMode} lexer action by calling * {@link Lexer//pushMode} with the assigned mode */ export default class LexerPushModeAction extends LexerAction { constructor(mode) { super(LexerActionType.PUSH_MODE); this.mode = mode; } /** * <p>This action is implemented by calling {@link Lexer//pushMode} with the * value provided by {@link //getMode}.</p> */ execute(lexer) { lexer.pushMode(this.mode); } updateHashCode(hash) { hash.update(this.actionType, this.mode); } equals(other) { if (this === other) { return true; } else if (! (other instanceof LexerPushModeAction)) { return false; } else { return this.mode === other.mode; } } toString() { return "pushMode(" + this.mode + ")"; } }