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