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