Add RuleDependencyAttribute
This commit is contained in:
parent
42d3ff06d3
commit
cc00681bf8
|
@ -154,6 +154,7 @@
|
|||
<Compile Include="RecognitionException.cs" />
|
||||
<Compile Include="Recognizer`2.cs" />
|
||||
<Compile Include="RuleContext.cs" />
|
||||
<Compile Include="RuleDependencyAttribute.cs" />
|
||||
<Compile Include="RuleVersionAttribute.cs" />
|
||||
<Compile Include="Sharpen\Arrays.cs" />
|
||||
<Compile Include="Sharpen\AtomicReference`1.cs" />
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
namespace Antlr4.Runtime
|
||||
{
|
||||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
|
||||
public sealed class RuleDependencyAttribute : Attribute
|
||||
{
|
||||
private readonly Type _recognizer;
|
||||
private readonly int _rule;
|
||||
private readonly int _version;
|
||||
private readonly Dependents _dependents;
|
||||
|
||||
public RuleDependencyAttribute(Type recognizer, int rule, int version)
|
||||
{
|
||||
this._recognizer = recognizer;
|
||||
this._rule = rule;
|
||||
this._version = version;
|
||||
this._dependents = Dependents.Parents | Dependents.Self;
|
||||
}
|
||||
|
||||
public RuleDependencyAttribute(Type recognizer, int rule, int version, Dependents dependents)
|
||||
{
|
||||
this._recognizer = recognizer;
|
||||
this._rule = rule;
|
||||
this._version = version;
|
||||
this._dependents = dependents | Dependents.Self;
|
||||
}
|
||||
|
||||
public Type Recognizer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _recognizer;
|
||||
}
|
||||
}
|
||||
|
||||
public int Rule
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rule;
|
||||
}
|
||||
}
|
||||
|
||||
public int Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
}
|
||||
|
||||
public Dependents Dependents
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dependents;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue