1 /* 2 * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 * Use of this file is governed by the BSD 3-clause license that 4 * can be found in the LICENSE.txt file in the project root. 5 */ 6 7 package org.antlr.v4.runtime.atn; 8 9 import org.antlr.v4.runtime.Lexer; 10 import org.antlr.v4.runtime.misc.MurmurHash; 11 12 /** 13 * Implements the {@code more} lexer action by calling {@link Lexer#more}. 14 * 15 * <p>The {@code more} command does not have any parameters, so this action is 16 * implemented as a singleton instance exposed by {@link #INSTANCE}.</p> 17 * 18 * @author Sam Harwell 19 * @since 4.2 20 */ 21 public final class LexerMoreAction implements LexerAction { 22 /** 23 * Provides a singleton instance of this parameterless lexer action. 24 */ 25 public static final LexerMoreAction INSTANCE = new LexerMoreAction(); 26 27 /** 28 * Constructs the singleton instance of the lexer {@code more} command. 29 */ LexerMoreAction()30 private LexerMoreAction() { 31 } 32 33 /** 34 * {@inheritDoc} 35 * @return This method returns {@link LexerActionType#MORE}. 36 */ 37 @Override getActionType()38 public LexerActionType getActionType() { 39 return LexerActionType.MORE; 40 } 41 42 /** 43 * {@inheritDoc} 44 * @return This method returns {@code false}. 45 */ 46 @Override isPositionDependent()47 public boolean isPositionDependent() { 48 return false; 49 } 50 51 /** 52 * {@inheritDoc} 53 * 54 * <p>This action is implemented by calling {@link Lexer#more}.</p> 55 */ 56 @Override execute(Lexer lexer)57 public void execute(Lexer lexer) { 58 lexer.more(); 59 } 60 61 @Override hashCode()62 public int hashCode() { 63 int hash = MurmurHash.initialize(); 64 hash = MurmurHash.update(hash, getActionType().ordinal()); 65 return MurmurHash.finish(hash, 1); 66 } 67 68 @Override 69 @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") equals(Object obj)70 public boolean equals(Object obj) { 71 return obj == this; 72 } 73 74 @Override toString()75 public String toString() { 76 return "more"; 77 } 78 } 79