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