File tree Expand file tree Collapse file tree 8 files changed +423
-364
lines changed
Expand file tree Collapse file tree 8 files changed +423
-364
lines changed Original file line number Diff line number Diff line change @@ -1163,10 +1163,12 @@ type Bit struct {
11631163}
11641164
11651165type Enum struct {
1166+ parent Meta
11661167 ident string
11671168 desc string
11681169 ref string
11691170 val int
1171+ ifs []* IfFeature
11701172 extensions []* Extension
11711173}
11721174
Original file line number Diff line number Diff line change @@ -4216,6 +4216,14 @@ func (m *Enum) Ident() string {
42164216 return m .ident
42174217}
42184218
4219+ // Parent is where this extension is define unless the extension is a
4220+ // secondary extension like a description and then this is the parent
4221+ // of that description
4222+ func (m * Enum ) Parent () Meta {
4223+ return m .parent
4224+ }
4225+
4226+
42194227// Description of Enum
42204228func (m * Enum ) Description () string {
42214229 return m .desc
@@ -4242,6 +4250,15 @@ func (m *Enum) addExtension(extension *Extension) {
42424250}
42434251
42444252
4253+ func (m * Enum ) IfFeatures () []* IfFeature {
4254+ return m .ifs
4255+ }
4256+
4257+ func (m * Enum ) addIfFeature (i * IfFeature ) {
4258+ i .parent = m
4259+ m .ifs = append (m .ifs , i )
4260+ }
4261+
42454262
42464263
42474264// Description of Range
Original file line number Diff line number Diff line change @@ -608,7 +608,6 @@ error_app_tag_stmt :
608608 }
609609 }
610610
611-
612611if_feature_stmt :
613612 kywd_if_feature string_value statement_end {
614613 l := yylex.(*lexer)
@@ -1489,6 +1488,7 @@ enum_body_stmt :
14891488 | status_stmt
14901489 | reference_stmt
14911490 | enum_value
1491+ | if_feature_stmt
14921492 | unknown_stmt
14931493
14941494enum_value :
Original file line number Diff line number Diff line change 2323 "leaf" :{
2424 "type" :{
2525 "ident" :" string" ,
26- "format" :" string" }}}]}}],
26+ "format" :" string" }}}]}},
27+ {
28+ "ident" :" l3" ,
29+ "leaf" :{
30+ "type" :{
31+ "ident" :" enumeration" ,
32+ "enumeration" :[
33+ {
34+ "label" :" one" ,
35+ "id" :0 },
36+ {
37+ "label" :" two" ,
38+ "id" :1 }],
39+ "format" :" enum" }}}],
2740 "feature" :[
2841 {
2942 "ident" :" blacklisted" },
Original file line number Diff line number Diff line change @@ -47,6 +47,24 @@ type "type"
4747; ";"
4848} "}"
4949} "}"
50+ leaf " leaf"
51+ [ident] "l3"
52+ { "{"
53+ type " type"
54+ [ident] "enumeratio"...
55+ { "{"
56+ enum " enum"
57+ [string] "one"
58+ { "{"
59+ if-feature " if-feature"
60+ [string] "\"x\""
61+ ; ";"
62+ } "}"
63+ enum " enum"
64+ [string] "two"
65+ ; ";"
66+ } "}"
67+ } "}"
5068uses " uses"
5169[ident] "g"
5270{ "{"
Original file line number Diff line number Diff line change @@ -24,6 +24,15 @@ module x {
2424 }
2525 }
2626
27+ leaf l3 {
28+ type enumeration {
29+ enum one {
30+ if-feature "x" ;
31+ }
32+ enum two;
33+ }
34+ }
35+
2736 uses g {
2837 if-feature blacklisted;
2938 }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ module fc-yang {
1313
1414 /*
1515 * NOTES:
16-
16+ *
1717 * !! contains CIRCULAR references however there is no other way around
1818 * this. According to RFC7950 this is not allowed.
1919 */
You can’t perform that action at this time.
0 commit comments