forked from sleepinggenius2/gosmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.go
56 lines (42 loc) · 1.54 KB
/
type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package parser
import (
"github.com/alecthomas/participle/lexer"
"github.com/min-oc/gosmi/types"
)
type TextualConvention struct {
Pos lexer.Position
DisplayHint string `parser:"( \"DISPLAY-HINT\" @Text )?"`
Status Status `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required
Description string `parser:"\"DESCRIPTION\" @Text"` // Required
Reference string `parser:"( \"REFERENCE\" @Text )?"`
Syntax SyntaxType `parser:"\"SYNTAX\" @@"` // Required
}
type SequenceEntry struct {
Pos lexer.Position
Descriptor types.SmiIdentifier `parser:"@Ident"`
Syntax SyntaxType `parser:"@@"`
}
type SequenceType string
const (
SequenceTypeChoice SequenceType = "CHOICE"
SequenceTypeSequence SequenceType = "SEQUENCE"
)
type Sequence struct {
Pos lexer.Position
Type SequenceType `parser:"@( \"CHOICE\" | \"SEQUENCE\" )"`
Entries []SequenceEntry `parser:"\"{\" @@ ( \",\" @@ )* \",\"? \"}\""`
}
type Implicit struct {
Pos lexer.Position
Application bool `parser:"\"[\" @\"APPLICATION\"?"`
Number int `parser:"@Int \"]\""`
Syntax SyntaxType `parser:"\"IMPLICIT\" @@"`
}
type Type struct {
Pos lexer.Position
Name types.SmiIdentifier `parser:"@Ident Assign"`
TextualConvention *TextualConvention `parser:"( ( \"TEXTUAL-CONVENTION\" @@ )"`
Sequence *Sequence `parser:"| @@"`
Implicit *Implicit `parser:"| @@"`
Syntax *SyntaxType `parser:"| @@ )"`
}