]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/LexerPushModeAction.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / LexerPushModeAction.h
1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 #pragma once
7
8 #include "atn/LexerAction.h"
9 #include "atn/LexerActionType.h"
10
11 namespace antlr4 {
12 namespace atn {
13
14   /// <summary>
15   /// Implements the {@code pushMode} lexer action by calling
16   /// <seealso cref="Lexer#pushMode"/> with the assigned mode.
17   ///
18   /// @author Sam Harwell
19   /// @since 4.2
20   /// </summary>
21   class ANTLR4CPP_PUBLIC LexerPushModeAction final : public LexerAction {
22   public:
23     /// <summary>
24     /// Constructs a new {@code pushMode} action with the specified mode value. </summary>
25     /// <param name="mode"> The mode value to pass to <seealso cref="Lexer#pushMode"/>. </param>
26     LexerPushModeAction(int mode);
27
28     /// <summary>
29     /// Get the lexer mode this action should transition the lexer to.
30     /// </summary>
31     /// <returns> The lexer mode for this {@code pushMode} command. </returns>
32     int getMode() const;
33
34     /// <summary>
35     /// {@inheritDoc} </summary>
36     /// <returns> This method returns <seealso cref="LexerActionType#PUSH_MODE"/>. </returns>
37     virtual LexerActionType getActionType() const override;
38
39     /// <summary>
40     /// {@inheritDoc} </summary>
41     /// <returns> This method returns {@code false}. </returns>
42     virtual bool isPositionDependent() const override;
43
44     /// <summary>
45     /// {@inheritDoc}
46     ///
47     /// <para>This action is implemented by calling <seealso cref="Lexer#pushMode"/> with the
48     /// value provided by <seealso cref="#getMode"/>.</para>
49     /// </summary>
50     virtual void execute(Lexer *lexer) override;
51
52     virtual size_t hashCode() const override;
53     virtual bool operator == (const LexerAction &obj) const override;
54     virtual std::string toString() const override;
55
56   private:
57     const int _mode;
58   };
59
60 } // namespace atn
61 } // namespace antlr4