]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/LexerChannelAction.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / LexerChannelAction.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   using antlr4::Lexer;
15
16   /// <summary>
17   /// Implements the {@code channel} lexer action by calling
18   /// <seealso cref="Lexer#setChannel"/> with the assigned channel.
19   ///
20   /// @author Sam Harwell
21   /// @since 4.2
22   /// </summary>
23   class ANTLR4CPP_PUBLIC LexerChannelAction final : public LexerAction {
24   public:
25     /// <summary>
26     /// Constructs a new {@code channel} action with the specified channel value. </summary>
27     /// <param name="channel"> The channel value to pass to <seealso cref="Lexer#setChannel"/>. </param>
28     LexerChannelAction(int channel);
29
30     /// <summary>
31     /// Gets the channel to use for the <seealso cref="Token"/> created by the lexer.
32     /// </summary>
33     /// <returns> The channel to use for the <seealso cref="Token"/> created by the lexer. </returns>
34     int getChannel() const;
35
36     /// <summary>
37     /// {@inheritDoc} </summary>
38     /// <returns> This method returns <seealso cref="LexerActionType#CHANNEL"/>. </returns>
39     virtual LexerActionType getActionType() const override;
40
41     /// <summary>
42     /// {@inheritDoc} </summary>
43     /// <returns> This method returns {@code false}. </returns>
44     virtual bool isPositionDependent() const override;
45
46     /// <summary>
47     /// {@inheritDoc}
48     ///
49     /// <para>This action is implemented by calling <seealso cref="Lexer#setChannel"/> with the
50     /// value provided by <seealso cref="#getChannel"/>.</para>
51     /// </summary>
52     virtual void execute(Lexer *lexer) override;
53
54     virtual size_t hashCode() const override;
55     virtual bool operator == (const LexerAction &obj) const override;
56     virtual std::string toString() const override;
57
58   private:
59     const int _channel;
60   };
61
62 } // namespace atn
63 } // namespace antlr4