1 /* 2 * Copyright (c) 2012-2018 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 module antlr.v4.runtime.atn.LexerPopModeAction; 8 9 import antlr.v4.runtime.InterfaceLexer; 10 import antlr.v4.runtime.atn.LexerAction; 11 import antlr.v4.runtime.atn.LexerActionType; 12 import antlr.v4.runtime.misc; 13 14 // Singleton LexerPopModeAction 15 /** 16 * Implements the {@code popMode} lexer action by calling {@link Lexer#popMode}. 17 * 18 * <p>The {@code popMode} command does not have any parameters, so this action is 19 * implemented as a singleton instance exposed by {@link #INSTANCE}.</p> 20 */ 21 class LexerPopModeAction : LexerAction 22 { 23 24 /** 25 * The single instance of LexerPopModeAction. 26 */ 27 private static __gshared LexerPopModeAction instance_; 28 29 /** 30 * @uml 31 * {@inheritDoc} 32 * @return This method returns {@link LexerActionType#POP_MODE}. 33 * @safe 34 * @nothrow 35 */ 36 public LexerActionType getActionType() @safe nothrow 37 { 38 return LexerActionType.POP_MODE; 39 } 40 41 /** 42 * @uml 43 * {@inheritDoc} 44 * @return This method returns {@code false}. 45 */ 46 public bool isPositionDependent() 47 { 48 return false; 49 } 50 51 /** 52 * @uml 53 * {@inheritDoc} 54 * 55 * <p>This action is implemented by calling {@link Lexer#popMode}.</p> 56 */ 57 public void execute(InterfaceLexer lexer) 58 { 59 lexer.popMode(); 60 } 61 62 /** 63 * @uml 64 * @override 65 */ 66 public override size_t toHash() 67 { 68 size_t hash = MurmurHash.initialize(); 69 hash = MurmurHash.update(hash, Utils.rank(getActionType)); 70 return MurmurHash.finish(hash, 1); 71 } 72 73 /** 74 * @uml 75 * - @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") 76 */ 77 public bool equals(Object obj) 78 { 79 return obj == this; 80 } 81 82 /** 83 * @uml 84 * @override 85 */ 86 public override string toString() 87 { 88 return "popMode"; 89 } 90 91 /** 92 * Creates the single instance of LexerPopModeAction. 93 */ 94 private shared static this() 95 { 96 instance_ = new LexerPopModeAction; 97 } 98 99 /** 100 * Returns: A single instance of LexerPopModeAction. 101 */ 102 public static LexerPopModeAction instance() 103 { 104 return instance_; 105 } 106 107 }