]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/LexerTypeAction.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / LexerTypeAction.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/LexerActionType.h"
9 #include "atn/LexerAction.h"
10
11 namespace antlr4 {
12 namespace atn {
13
14   /// Implements the {@code type} lexer action by calling <seealso cref="Lexer#setType"/>
15   /// with the assigned type.
16   class ANTLR4CPP_PUBLIC LexerTypeAction : public LexerAction {
17   public:
18     /// <summary>
19     /// Constructs a new {@code type} action with the specified token type value. </summary>
20     /// <param name="type"> The type to assign to the token using <seealso cref="Lexer#setType"/>. </param>
21     LexerTypeAction(int type);
22
23     /// <summary>
24     /// Gets the type to assign to a token created by the lexer. </summary>
25     /// <returns> The type to assign to a token created by the lexer. </returns>
26     virtual int getType() const;
27
28     /// <summary>
29     /// {@inheritDoc} </summary>
30     /// <returns> This method returns <seealso cref="LexerActionType#TYPE"/>. </returns>
31     virtual LexerActionType getActionType() const override;
32
33     /// <summary>
34     /// {@inheritDoc} </summary>
35     /// <returns> This method returns {@code false}. </returns>
36     virtual bool isPositionDependent() const override;
37
38     /// <summary>
39     /// {@inheritDoc}
40     ///
41     /// <para>This action is implemented by calling <seealso cref="Lexer#setType"/> with the
42     /// value provided by <seealso cref="#getType"/>.</para>
43     /// </summary>
44     virtual void execute(Lexer *lexer) override;
45
46     virtual size_t hashCode() const override;
47     virtual bool operator == (const LexerAction &obj) const override;
48     virtual std::string toString() const override;
49
50   private:
51     const int _type;
52   };
53
54 } // namespace atn
55 } // namespace antlr4