1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Misc;
using Antlr4.Runtime.Sharpen;
namespace Antlr4.Runtime.Atn
{
/// <summary>
/// Implements the
/// <c>pushMode</c>
/// lexer action by calling
/// <see cref="Antlr4.Runtime.Lexer.PushMode(int)"/>
/// with the assigned mode.
/// </summary>
/// <author>Sam Harwell</author>
/// <since>4.2</since>
public sealed class LexerPushModeAction : ILexerAction
{
private readonly int mode;
/// <summary>
/// Constructs a new
/// <c>pushMode</c>
/// action with the specified mode value.
/// </summary>
/// <param name="mode">
/// The mode value to pass to
/// <see cref="Antlr4.Runtime.Lexer.PushMode(int)"/>
/// .
/// </param>
public LexerPushModeAction(int mode)
{
this.mode = mode;
}
/// <summary>Get the lexer mode this action should transition the lexer to.</summary>
/// <remarks>Get the lexer mode this action should transition the lexer to.</remarks>
/// <returns>
/// The lexer mode for this
/// <c>pushMode</c>
/// command.
/// </returns>
public int Mode
{
get
{
return mode;
}
}
/// <summary><inheritDoc/></summary>
/// <returns>
/// This method returns
/// <see cref="LexerActionType.PushMode"/>
/// .
/// </returns>
public LexerActionType ActionType
{
get
{
return LexerActionType.PushMode;
}
}
/// <summary><inheritDoc/></summary>
/// <returns>
/// This method returns
/// <see langword="false"/>
/// .
/// </returns>
public bool IsPositionDependent
{
get
{
return false;
}
}
/// <summary>
/// <inheritDoc/>
/// <p>This action is implemented by calling
/// <see cref="Antlr4.Runtime.Lexer.PushMode(int)"/>
/// with the
/// value provided by
/// <see cref="Mode()"/>
/// .</p>
/// </summary>
public void Execute(Lexer lexer)
{
lexer.PushMode(mode);
}
public override int GetHashCode()
{
int hash = MurmurHash.Initialize();
hash = MurmurHash.Update(hash, (int)(ActionType));
hash = MurmurHash.Update(hash, mode);
return MurmurHash.Finish(hash, 2);
}
public override bool Equals(object obj)
{
if (obj == this)
{
return true;
}
else
{
if (!(obj is Antlr4.Runtime.Atn.LexerPushModeAction))
{
return false;
}
}
return mode == ((Antlr4.Runtime.Atn.LexerPushModeAction)obj).mode;
}
public override string ToString()
{
return string.Format("pushMode({0})", mode);
}
}
}