Add RuleDependencyAttribute

This commit is contained in:
Sam Harwell 2013-02-25 15:08:24 -06:00
parent 42d3ff06d3
commit cc00681bf8
2 changed files with 62 additions and 0 deletions

View File

@ -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" />

View File

@ -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;
}
}
}
}