1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
6 #include "misc/MurmurHash.h"
9 #include "atn/LexerPushModeAction.h"
11 using namespace antlr4;
12 using namespace antlr4::atn;
13 using namespace antlr4::misc;
15 LexerPushModeAction::LexerPushModeAction(int mode) : _mode(mode) {
18 int LexerPushModeAction::getMode() const {
22 LexerActionType LexerPushModeAction::getActionType() const {
23 return LexerActionType::PUSH_MODE;
26 bool LexerPushModeAction::isPositionDependent() const {
30 void LexerPushModeAction::execute(Lexer *lexer) {
31 lexer->pushMode(_mode);
34 size_t LexerPushModeAction::hashCode() const {
35 size_t hash = MurmurHash::initialize();
36 hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
37 hash = MurmurHash::update(hash, _mode);
38 return MurmurHash::finish(hash, 2);
41 bool LexerPushModeAction::operator == (const LexerAction &obj) const {
46 const LexerPushModeAction *action = dynamic_cast<const LexerPushModeAction *>(&obj);
47 if (action == nullptr) {
51 return _mode == action->_mode;
54 std::string LexerPushModeAction::toString() const {
55 return "pushMode(" + std::to_string(_mode) + ")";