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/LexerTypeAction.h"
11 using namespace antlr4;
12 using namespace antlr4::atn;
13 using namespace antlr4::misc;
15 LexerTypeAction::LexerTypeAction(int type) : _type(type) {
18 int LexerTypeAction::getType() const {
22 LexerActionType LexerTypeAction::getActionType() const {
23 return LexerActionType::TYPE;
26 bool LexerTypeAction::isPositionDependent() const {
30 void LexerTypeAction::execute(Lexer *lexer) {
31 lexer->setType(_type);
34 size_t LexerTypeAction::hashCode() const {
35 size_t hash = MurmurHash::initialize();
36 hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
37 hash = MurmurHash::update(hash, _type);
38 return MurmurHash::finish(hash, 2);
41 bool LexerTypeAction::operator == (const LexerAction &obj) const {
46 const LexerTypeAction *action = dynamic_cast<const LexerTypeAction *>(&obj);
47 if (action == nullptr) {
51 return _type == action->_type;
54 std::string LexerTypeAction::toString() const {
55 return "type(" + std::to_string(_type) + ")";