@@ -20,16 +20,31 @@ Input <- conf:Conformance+ EOF {
2020 cs := conf.([]interface{})
2121
2222 var set Set
23- for _, i := range cs {
24- con := i.(Conformance)
23+ for i, e := range cs {
24+ con := e.(Conformance)
25+ switch con.(type) {
26+ case *Provisional:
27+ if i != 0 {
28+ return nil, fmt.Errorf("provisionality set at index %d; provisional annotations must be the first element of conformance", i)
29+ }
30+ case *Deprecated:
31+ if i == 0 || i != len(cs) - 1 {
32+ return nil, fmt.Errorf("deprecation set at index %d; deprecation annotations must be the last element in a set of conformances", i)
33+ }
34+ case *Obsolete:
35+ if i != len(cs) - 1 {
36+ return nil, fmt.Errorf("obsolete set at index %d; obsolete annotations must appear alone, or be the last element in a set of conformances", i)
37+ }
38+
39+ }
2540 set = append(set, con)
2641 }
2742 return set, nil
2843}
2944
3045ConformanceSeparator <- (_ Comma _) / &EOF
3146
32- Conformance <- '[' i:Expression ']' choice:Choice? ConformanceSeparator {
47+ Conformance <- '[' i:LogicalExpression ']' choice:Choice? ConformanceSeparator {
3348 exp := i.(Expression)
3449 o := &Optional{Expression:exp}
3550 if choice != nil {
@@ -51,14 +66,15 @@ Conformance <- '[' i:Expression ']' choice:Choice? ConformanceSeparator {
5166 return &Deprecated{}, nil
5267} / 'X' ConformanceSeparator {
5368 return &Disallowed{}, nil
69+ } / 'Z' ConformanceSeparator {
70+ return &Obsolete{}, nil
71+ }
5472} / "desc" ConformanceSeparator {
5573 return &Described{}, nil
56- } / eq:Expression ConformanceSeparator {
74+ } / eq:LogicalExpression ConformanceSeparator {
5775 exp := eq.(Expression)
5876 return &Mandatory{Expression:exp}, nil
5977}
6078
61- Expression <- LogicalExpression
62-
6379
6480
0 commit comments