retro_idl 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/ext/retro_idl/asn/ext_parser/ext_common.h +27 -0
  3. data/ext/retro_idl/asn/ext_parser/ext_parser.l +201 -0
  4. data/ext/retro_idl/asn/ext_parser/ext_parser.y +1207 -0
  5. data/ext/retro_idl/asn/ext_parser/extconf.rb +3 -0
  6. data/ext/retro_idl/asn/ext_parser/lexer.c +2873 -0
  7. data/ext/retro_idl/asn/ext_parser/lexer.h +366 -0
  8. data/ext/retro_idl/asn/ext_parser/parser.c +2963 -0
  9. data/ext/retro_idl/asn/ext_parser/parser.h +175 -0
  10. data/lib/retro_idl/asn/alternative_type.rb +43 -0
  11. data/lib/retro_idl/asn/asn.rb +309 -0
  12. data/lib/retro_idl/asn/asn_error.rb +2 -0
  13. data/lib/retro_idl/asn/base_type.rb +87 -0
  14. data/lib/retro_idl/asn/base_value.rb +75 -0
  15. data/lib/retro_idl/asn/bit_string.rb +44 -0
  16. data/lib/retro_idl/asn/boolean.rb +50 -0
  17. data/lib/retro_idl/asn/builtin_value.rb +51 -0
  18. data/lib/retro_idl/asn/choice.rb +95 -0
  19. data/lib/retro_idl/asn/component_type.rb +56 -0
  20. data/lib/retro_idl/asn/constraint.rb +162 -0
  21. data/lib/retro_idl/asn/defined_type.rb +61 -0
  22. data/lib/retro_idl/asn/defined_value.rb +82 -0
  23. data/lib/retro_idl/asn/enumerated.rb +127 -0
  24. data/lib/retro_idl/asn/enumeration_item.rb +103 -0
  25. data/lib/retro_idl/asn/integer.rb +84 -0
  26. data/lib/retro_idl/asn/location.rb +10 -0
  27. data/lib/retro_idl/asn/named_number.rb +83 -0
  28. data/lib/retro_idl/asn/null.rb +41 -0
  29. data/lib/retro_idl/asn/octetstring.rb +48 -0
  30. data/lib/retro_idl/asn/real.rb +36 -0
  31. data/lib/retro_idl/asn/sequence.rb +132 -0
  32. data/lib/retro_idl/asn/sequenceof.rb +62 -0
  33. data/lib/retro_idl/asn/single_value.rb +26 -0
  34. data/lib/retro_idl/asn/tag.rb +163 -0
  35. data/lib/retro_idl/asn/type_list.rb +121 -0
  36. data/lib/retro_idl/asn/value_assignment.rb +21 -0
  37. data/lib/retro_idl/asn/value_list.rb +48 -0
  38. data/lib/retro_idl.rb +20 -0
  39. data/rakefile +33 -0
  40. data/test/asn/ext_parser/capture_stderr.rb +20 -0
  41. data/test/asn/ext_parser/tc_ext_parser.rb +94 -0
  42. data/test/asn/parser/capture_stderr.rb +20 -0
  43. data/test/asn/parser/tc_parser.rb +90 -0
  44. metadata +133 -0
@@ -0,0 +1,127 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ # X.680 section 20
21
+ class RetroIDL::ASN::ENUMERATED < BaseType
22
+
23
+ TAG_CLASS_NUMBER = 10
24
+ TAG_CLASS = :universal
25
+
26
+ def initialize(**opts)
27
+
28
+ super(**opts)
29
+
30
+ errors = false
31
+
32
+ @exception = opts[:exception]
33
+ @extensible = opts[:extensible]
34
+ @additional = nil
35
+
36
+ begin
37
+
38
+ @root = ValueList.new(opts[:root], EnumerationItem)
39
+
40
+ rescue ASNError
41
+
42
+ errors = true
43
+
44
+ end
45
+
46
+ if opts[:additional]
47
+
48
+ begin
49
+
50
+ @additional = ValueList.new(opts[:additional], EnumerationItem)
51
+
52
+ rescue ASNError
53
+
54
+ errors = true
55
+
56
+ end
57
+
58
+ if @additional
59
+
60
+ @additional.list.each do |id, item|
61
+
62
+ if @root.list.keys.include? id
63
+
64
+ ASN.putError(item.location, "duplicate EnumerationItem")
65
+ errors = true
66
+
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+
75
+ if errors
76
+
77
+ raise ASNError.new
78
+
79
+ end
80
+
81
+ end
82
+
83
+ # @macro common_link
84
+ def link(mod, stack)
85
+
86
+ if @mod.nil? or @mod != mod
87
+
88
+ @mod = nil
89
+
90
+ if @root.link(mod, stack)
91
+
92
+ if @additional.nil? or @additional.link(mod, stack)
93
+
94
+ super(mod, stack)
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+
102
+ @mod
103
+
104
+ end
105
+
106
+ # @macro common_to_s
107
+ def to_s
108
+
109
+ result = "#{@tag} ENUMERATED { #{@root} "
110
+
111
+ if @extensible
112
+
113
+ result << ", ... "
114
+
115
+ end
116
+
117
+ result << "} #{@constraint}"
118
+
119
+ end
120
+
121
+ def evaluate(value)
122
+
123
+ false
124
+
125
+ end
126
+
127
+ end
@@ -0,0 +1,103 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+
21
+ # An item within an ENUMERATED type
22
+ #
23
+ # X.680 section 20
24
+ class RetroIDL::ASN::EnumerationItem
25
+
26
+ def initialize(**opts)
27
+
28
+ @id = opts[:id].to_s
29
+ @location = opts[:location]
30
+ @mod = nil
31
+ @symbol = nil
32
+ @number = nil
33
+
34
+ if RetroIDL::ASN.is_identifier?(@location, @id)
35
+ if opts[:number]
36
+ if opts[:number].is_a? String
37
+ @symbol = opts[:number].to_s
38
+ else
39
+ @number = opts[:number].to_i
40
+ end
41
+ end
42
+ else
43
+ raise ASNError
44
+ end
45
+
46
+ end
47
+
48
+ # @return [Hash] location record
49
+ attr_reader :location
50
+
51
+ # @macro common_link
52
+ def link(mod, stack)
53
+
54
+ if @mod.nil? or @mod != mod
55
+
56
+ @mod = nil
57
+
58
+ if @symbol
59
+
60
+ if mod.symbols(@symbol)
61
+
62
+ @mod = mod
63
+
64
+ else
65
+
66
+ ASN.putError(@location, SYMBOL_UNDEFINED_ERROR)
67
+
68
+ end
69
+
70
+ else
71
+
72
+ @mod = mod
73
+
74
+ end
75
+
76
+ end
77
+
78
+ @mod
79
+
80
+ end
81
+
82
+ # @macro common_to_s
83
+ def to_s
84
+
85
+ if @symbol
86
+
87
+ "#{@id} (#{@symbol})"
88
+
89
+ elsif @number
90
+
91
+ "#{@id} (#{@number})"
92
+
93
+ else
94
+
95
+ "#{@id}"
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+
@@ -0,0 +1,84 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+
21
+ # X.680 section 19
22
+ class RetroIDL::ASN::INTEGER < BaseType
23
+
24
+ TAG_CLASS_NUMBER = 2
25
+ TAG_CLASS = :universal
26
+
27
+ # @see BaseType#initialize
28
+ #
29
+ # @param opts [Hash]
30
+ #
31
+ # @option opts [Array<Hash>] :numberList NamedNumberList
32
+ #
33
+ # @raise [ASNError]
34
+ #
35
+ def initialize(**opts)
36
+ super(**opts)
37
+ @numberList = nil
38
+ if opts[:numberList]
39
+ @numberList = ValueList.new(opts[:numberList], NamedNumber)
40
+ end
41
+ end
42
+
43
+ # @macro common_link
44
+ def link(mod, stack)
45
+
46
+ if @mod.nil? or @mod != mod
47
+
48
+ @mod = nil
49
+
50
+ if @numberList.nil? or @numberList.link(mod, [])
51
+
52
+ super(mod, stack)
53
+
54
+ end
55
+
56
+ end
57
+
58
+ @mod
59
+
60
+ end
61
+
62
+ # @macro common_to_s
63
+ def to_s
64
+
65
+ result = "#{@tag} INTEGER"
66
+ if @numberList
67
+ result << @numberList.to_s
68
+ end
69
+ result << " #{@constraint}"
70
+
71
+ end
72
+
73
+ # @macro common_evaluate
74
+ def evaluate(value)
75
+ value.kind_of?(Integer)
76
+ end
77
+
78
+ def evaluateConstraint(value)
79
+ if evaluate(value) and ( @constrant.nil? or @constraint.evaluate(value) )
80
+ true
81
+ end
82
+ end
83
+
84
+ end
@@ -0,0 +1,10 @@
1
+ class RetroIDL::ASN::Location
2
+ attr_reader :fileName
3
+ def initialize(fileName, firstLine, lastLine, firstCol, lastCol)
4
+ @fileName = fileName
5
+ @firstLine = firstLine
6
+ @lastLine = lastLine
7
+ @firstCol = firstCol
8
+ @lastCol = lastCol
9
+ end
10
+ end
@@ -0,0 +1,83 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ class RetroIDL::ASN::NamedNumber
21
+
22
+ def initialize(**opts)
23
+
24
+ @id = opts[:id].to_s
25
+ @location = opts[:location]
26
+ @mod = nil
27
+ @number = nil
28
+ @symbol = nil
29
+
30
+ if RetroIDL::ASN.is_identifier?(@location, @id)
31
+ if opts[:number].is_a? String
32
+ @symbol = opts[:number].to_s
33
+ else
34
+ @number = opts[:number].to_i
35
+ end
36
+ else
37
+ raise ASNError
38
+ end
39
+
40
+ end
41
+
42
+ def link(mod, stack)
43
+
44
+ if @mod.nil? or @mod != mod
45
+
46
+ @mod = nil
47
+
48
+ if @symbol
49
+
50
+ if mod.symbols(@symbol)
51
+
52
+ @mod = mod
53
+
54
+ end
55
+
56
+ else
57
+
58
+ @mod = mod
59
+
60
+ end
61
+
62
+ else
63
+
64
+ @mod
65
+
66
+ end
67
+
68
+ end
69
+
70
+
71
+ # @macro common_to_s
72
+ def to_s
73
+
74
+ if @symbol
75
+ "#{@id} (#{@symbol})"
76
+ else
77
+ "#{@id} (#{@number})"
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ class RetroIDL::ASN::NULL < BaseType
21
+
22
+ TAG_CLASS_NUMBER = 5
23
+ TAG_CLASS = :universal
24
+
25
+ # @macro common_to_s
26
+ def to_s
27
+
28
+ "#{@tag} NULL #{@constraint}"
29
+
30
+ end
31
+
32
+ def evaluate(value)
33
+ value.nil?
34
+ end
35
+
36
+ def evaluateConstraint(value)
37
+ true
38
+ end
39
+
40
+ end
41
+
@@ -0,0 +1,48 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+
21
+ class RetroIDL::ASN::OCTETSTRING < BaseType
22
+
23
+ TAG_CLASS_NUMBER = 4
24
+ TAG_CLASS = :universal
25
+
26
+ # @macro common_to_s
27
+ def to_s
28
+
29
+ return "#{@tag} OCTET STRING #{@constraint}"
30
+
31
+ end
32
+
33
+ def evaluate(value)
34
+ value.kind_of?(String)
35
+ end
36
+
37
+ def evaluateConstraint(value)
38
+
39
+ if evaluate(value) and ( @constraint or @constraint.evaluate(value) )
40
+ true
41
+ else
42
+ false
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ class RetroIDL::ASN::REAL < BaseType
21
+
22
+ TAG_CLASS_NUMBER = 9
23
+ TAG_CLASS = :universal
24
+
25
+ # @macro common_to_s
26
+ def to_s
27
+
28
+ "#{@tag} REAL #{@constraint}"
29
+
30
+ end
31
+
32
+ def evaluate(value)
33
+ value.kind_of?(Numeric)
34
+ end
35
+
36
+ end
@@ -0,0 +1,132 @@
1
+ # Copyright (c) 2016 Cameron Harper
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+
21
+ class RetroIDL::ASN::SEQUENCE < BaseType
22
+
23
+ TAG_CLASS_NUMBER = 16
24
+ TAG_CLASS = :universal
25
+
26
+ def initialize(**opts)
27
+
28
+ super(**opts)
29
+
30
+ errors = false
31
+
32
+ @exception = opts[:exception]
33
+ @extensible = opts[:extensible]
34
+ @head = nil
35
+ @tail = nil
36
+ @additional = nil
37
+
38
+ if opts[:head]
39
+
40
+ begin
41
+
42
+ @head = TypeList.new(opts[:head], ComponentType)
43
+
44
+ rescue ASNError
45
+
46
+ errors = true
47
+
48
+ end
49
+
50
+ end
51
+
52
+ if opts[:additional]
53
+
54
+ begin
55
+
56
+ @additional = TypeList.new(opts[:additional], ComponentType)
57
+
58
+ rescue ASNError
59
+
60
+ errors = true
61
+
62
+ end
63
+
64
+ end
65
+
66
+ if opts[:tail]
67
+
68
+ begin
69
+
70
+ @tail = TypeList.new(opts[:tail], ComponentType)
71
+
72
+ rescue ASNError
73
+
74
+ errors = true
75
+
76
+ end
77
+
78
+ end
79
+
80
+ if errors
81
+
82
+ raise ASNError.new
83
+
84
+ end
85
+
86
+ end
87
+
88
+ # @macro common_link
89
+ def link(mod, stack)
90
+
91
+ if @mod.nil? or @mod != mod
92
+
93
+ @mod = nil
94
+
95
+ if @head.nil? or @head.link(mod, stack)
96
+
97
+ if @tail.nil? or @tail.link(mod, stack)
98
+
99
+ if @additional.nil? or @additional.link(mod, stack)
100
+
101
+ super(mod, [])
102
+
103
+ end
104
+
105
+ end
106
+
107
+ end
108
+
109
+ else
110
+
111
+ @mod
112
+
113
+ end
114
+
115
+ end
116
+
117
+ # @macro common_to_s
118
+ def to_s
119
+
120
+ result = "#{@tag} SEQUENCE { #{@head} "
121
+
122
+ if @extensible
123
+
124
+ result << ", ... "
125
+
126
+ end
127
+
128
+ result << "} #{@constraint}"
129
+
130
+ end
131
+
132
+ end