-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3155309
commit 34d2abd
Showing
3 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace YangParser.SemanticModel; | ||
|
||
public class Action : Statement | ||
{ | ||
|
||
public Action(YangStatement statement) | ||
{ | ||
if (statement.Keyword != Keyword) | ||
throw new InvalidOperationException($"Non-matching Keyword '{statement.Keyword}', expected {Keyword}"); | ||
Argument = statement.Argument!.ToString(); | ||
ValidateChildren(statement); | ||
Children = statement.Children.Select(StatementFactory.Create).ToArray(); | ||
} | ||
|
||
public const string Keyword = "action"; | ||
|
||
public override ChildRule[] PermittedChildren { get; } = | ||
[ | ||
new ChildRule(Description.Keyword), | ||
new ChildRule(Grouping.Keyword, Cardinality.ZeroOrMore), | ||
new ChildRule(FeatureFlag.Keyword, Cardinality.ZeroOrMore), | ||
new ChildRule(Input.Keyword), | ||
new ChildRule(Output.Keyword), | ||
new ChildRule(Reference.Keyword), | ||
new ChildRule(Status.Keyword), | ||
new ChildRule(TypeDefinition.Keyword, Cardinality.ZeroOrMore), | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
namespace YangParser.SemanticModel.Builtins; | ||
|
||
public class BuiltinType(string name, string? correspondingCSharpType) | ||
{ | ||
public string Name => name; | ||
public string? CorrespondingCSharpType => correspondingCSharpType; | ||
} | ||
|
||
public class Binary() : BuiltinType("binary", "byte[]"); | ||
|
||
public class Bits() : BuiltinType("bits", null); | ||
|
||
public class Boolean() : BuiltinType("boolean", "bool"); | ||
|
||
public class Decimal64() : BuiltinType("decimal64", "double"); | ||
|
||
public class Empty() : BuiltinType("empty", null); | ||
|
||
public class Enumeration() : BuiltinType("enumeration", "enum"); | ||
|
||
public class IdentityReference() : BuiltinType("identityref", null); | ||
|
||
public class InstanceIdentifier() : BuiltinType("instance-identifier", null); | ||
|
||
public class Int8() : BuiltinType("int8", "sbyte"); | ||
|
||
public class Int16() : BuiltinType("int16", "short"); | ||
|
||
public class Int32() : BuiltinType("int32", "int"); | ||
|
||
public class Int64() : BuiltinType("int64", "long"); | ||
|
||
public class LeafReference() : BuiltinType("leafref", null); | ||
|
||
public class String() : BuiltinType("string", "string"); | ||
|
||
public class Uint8() : BuiltinType("uint8", "byte"); | ||
|
||
public class Uint16() : BuiltinType("uint16", "ushort"); | ||
|
||
public class Uint32() : BuiltinType("uint32", "uint"); | ||
|
||
public class Uint64() : BuiltinType("uint64", "ulong"); | ||
|
||
public class Union() : BuiltinType("union", null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters