retro_idl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/retro_idl/asn/ext_parser/ext_common.h +27 -0
- data/ext/retro_idl/asn/ext_parser/ext_parser.l +201 -0
- data/ext/retro_idl/asn/ext_parser/ext_parser.y +1207 -0
- data/ext/retro_idl/asn/ext_parser/extconf.rb +3 -0
- data/ext/retro_idl/asn/ext_parser/lexer.c +2873 -0
- data/ext/retro_idl/asn/ext_parser/lexer.h +366 -0
- data/ext/retro_idl/asn/ext_parser/parser.c +2963 -0
- data/ext/retro_idl/asn/ext_parser/parser.h +175 -0
- data/lib/retro_idl/asn/alternative_type.rb +43 -0
- data/lib/retro_idl/asn/asn.rb +309 -0
- data/lib/retro_idl/asn/asn_error.rb +2 -0
- data/lib/retro_idl/asn/base_type.rb +87 -0
- data/lib/retro_idl/asn/base_value.rb +75 -0
- data/lib/retro_idl/asn/bit_string.rb +44 -0
- data/lib/retro_idl/asn/boolean.rb +50 -0
- data/lib/retro_idl/asn/builtin_value.rb +51 -0
- data/lib/retro_idl/asn/choice.rb +95 -0
- data/lib/retro_idl/asn/component_type.rb +56 -0
- data/lib/retro_idl/asn/constraint.rb +162 -0
- data/lib/retro_idl/asn/defined_type.rb +61 -0
- data/lib/retro_idl/asn/defined_value.rb +82 -0
- data/lib/retro_idl/asn/enumerated.rb +127 -0
- data/lib/retro_idl/asn/enumeration_item.rb +103 -0
- data/lib/retro_idl/asn/integer.rb +84 -0
- data/lib/retro_idl/asn/location.rb +10 -0
- data/lib/retro_idl/asn/named_number.rb +83 -0
- data/lib/retro_idl/asn/null.rb +41 -0
- data/lib/retro_idl/asn/octetstring.rb +48 -0
- data/lib/retro_idl/asn/real.rb +36 -0
- data/lib/retro_idl/asn/sequence.rb +132 -0
- data/lib/retro_idl/asn/sequenceof.rb +62 -0
- data/lib/retro_idl/asn/single_value.rb +26 -0
- data/lib/retro_idl/asn/tag.rb +163 -0
- data/lib/retro_idl/asn/type_list.rb +121 -0
- data/lib/retro_idl/asn/value_assignment.rb +21 -0
- data/lib/retro_idl/asn/value_list.rb +48 -0
- data/lib/retro_idl.rb +20 -0
- data/rakefile +33 -0
- data/test/asn/ext_parser/capture_stderr.rb +20 -0
- data/test/asn/ext_parser/tc_ext_parser.rb +94 -0
- data/test/asn/parser/capture_stderr.rb +20 -0
- data/test/asn/parser/tc_parser.rb +90 -0
- metadata +133 -0
@@ -0,0 +1,1207 @@
|
|
1
|
+
/* Bison Configuration
|
2
|
+
*
|
3
|
+
* Cameron Harper 2016
|
4
|
+
*
|
5
|
+
* */
|
6
|
+
%{
|
7
|
+
|
8
|
+
/* includes ***********************************************************/
|
9
|
+
|
10
|
+
#include <stdio.h>
|
11
|
+
#include <stdlib.h>
|
12
|
+
#include <stdbool.h>
|
13
|
+
#include <ruby.h>
|
14
|
+
#include <assert.h>
|
15
|
+
|
16
|
+
#include "lexer.h"
|
17
|
+
|
18
|
+
/* local prototypes ***************************************************/
|
19
|
+
|
20
|
+
/**
|
21
|
+
* - Ruby method to take a hash of attributes and return a tree of parsed data
|
22
|
+
*
|
23
|
+
* <code>
|
24
|
+
* attr = {
|
25
|
+
* :buffer => [a ruby string containing the file],
|
26
|
+
* :filename => [a ruby string containing the filename]
|
27
|
+
* }
|
28
|
+
* </code>
|
29
|
+
*
|
30
|
+
* @param[in] self reciever
|
31
|
+
* @param[in] attr hash of attributes
|
32
|
+
*
|
33
|
+
* @return tree of parsed data
|
34
|
+
*
|
35
|
+
* */
|
36
|
+
static VALUE parseFileBuffer(VALUE self, VALUE attr);
|
37
|
+
|
38
|
+
/**
|
39
|
+
* - Create a Ruby location record from YYLTYPE structure
|
40
|
+
* - Returned structure is a Hash with keys for location values
|
41
|
+
*
|
42
|
+
* @param[in] filename filename corresponding to location record
|
43
|
+
* @param[in] location pointer to Bison location record
|
44
|
+
*
|
45
|
+
* @return Ruby location instance
|
46
|
+
*
|
47
|
+
* */
|
48
|
+
static VALUE newLocation(VALUE filename, YYLTYPE *location);
|
49
|
+
|
50
|
+
/**
|
51
|
+
* - Mandatory yyerror function called by Flex/Bison
|
52
|
+
* - variadic like printf
|
53
|
+
*
|
54
|
+
* @param[in] locp pointer to Bison location record
|
55
|
+
* @param[in] scanner pointer to scanner instance (this is a pure parser)
|
56
|
+
* @param[in] filename filename corresponding to location record
|
57
|
+
* @param[out] tree the return structure
|
58
|
+
* @param[in] msg printf format string
|
59
|
+
*
|
60
|
+
* */
|
61
|
+
void yyerror(YYLTYPE *locp, yyscan_t scanner, VALUE filename, VALUE *tree, char const *msg, ... );
|
62
|
+
|
63
|
+
/* static variables ***************************************************/
|
64
|
+
|
65
|
+
static VALUE ASN;
|
66
|
+
|
67
|
+
/* generated **********************************************************/
|
68
|
+
|
69
|
+
%}
|
70
|
+
|
71
|
+
%define api.value.type {VALUE}
|
72
|
+
%define api.pure full
|
73
|
+
%locations
|
74
|
+
%lex-param {yyscan_t scanner}
|
75
|
+
%parse-param {yyscan_t scanner}{VALUE filename}{VALUE *tree}
|
76
|
+
%define parse.error verbose
|
77
|
+
|
78
|
+
%nonassoc EXCEPT
|
79
|
+
%left CARET INTERSECTION
|
80
|
+
%left PIPE UNION
|
81
|
+
|
82
|
+
%define api.token.prefix {TOK_}
|
83
|
+
|
84
|
+
%token
|
85
|
+
ENDL
|
86
|
+
LVERSION "[["
|
87
|
+
ASSIGN "::="
|
88
|
+
RANGE ".."
|
89
|
+
ELLIPSES "..."
|
90
|
+
EXCEPT
|
91
|
+
UNION
|
92
|
+
INTERSECTION
|
93
|
+
EXCLAIM
|
94
|
+
OCTET
|
95
|
+
CHARACTER
|
96
|
+
BIT
|
97
|
+
STRING
|
98
|
+
SIZE
|
99
|
+
CHOICE
|
100
|
+
SEQUENCE
|
101
|
+
SET
|
102
|
+
OF
|
103
|
+
ALL
|
104
|
+
MIN
|
105
|
+
MAX
|
106
|
+
COMPONENTS
|
107
|
+
COMPONENT
|
108
|
+
ABSENT
|
109
|
+
CONTAINING
|
110
|
+
FROM
|
111
|
+
INCLUDES
|
112
|
+
SETTINGS
|
113
|
+
PRESENT
|
114
|
+
PATTERN
|
115
|
+
WITH
|
116
|
+
OPTIONAL
|
117
|
+
DEFAULT
|
118
|
+
IMPLICIT
|
119
|
+
EXPLICIT
|
120
|
+
APPLICATION
|
121
|
+
PRIVATE
|
122
|
+
UNIVERSAL
|
123
|
+
CHAR
|
124
|
+
BOOLEAN
|
125
|
+
INTEGER
|
126
|
+
REAL
|
127
|
+
ENUMERATED
|
128
|
+
BMPString
|
129
|
+
GeneralString
|
130
|
+
GraphicString
|
131
|
+
IA5String
|
132
|
+
ISO646String
|
133
|
+
NumericString
|
134
|
+
PrintableString
|
135
|
+
TeletexString
|
136
|
+
T61String
|
137
|
+
UniversalString
|
138
|
+
UTF8String
|
139
|
+
VideotexString
|
140
|
+
VisibleString
|
141
|
+
DATE
|
142
|
+
DATE_TIME
|
143
|
+
DURATION
|
144
|
+
EMBEDDED
|
145
|
+
PDV
|
146
|
+
EXTERNAL
|
147
|
+
RELATIVE_OID_IRI
|
148
|
+
OBJECT
|
149
|
+
IDENTIFIER
|
150
|
+
RELATIVE_IRI
|
151
|
+
RELATIVE_OID
|
152
|
+
TIME
|
153
|
+
TIME_OF_DAY
|
154
|
+
POSINT "positive integer"
|
155
|
+
NEGINT "negative integer"
|
156
|
+
HEXINT
|
157
|
+
ID "identifier"
|
158
|
+
RVERSION "]]"
|
159
|
+
PLUS_INFINITY
|
160
|
+
MINUS_INFINITY
|
161
|
+
NOT_A_NUMBER
|
162
|
+
TRUE
|
163
|
+
FALSE
|
164
|
+
NULL
|
165
|
+
CONTAINS
|
166
|
+
POSREAL "positive real number"
|
167
|
+
NEGREAL "negative real number"
|
168
|
+
HSTRING "hstring"
|
169
|
+
BSTRING "bstring"
|
170
|
+
CSTRING "cstring"
|
171
|
+
DEFINITIONS
|
172
|
+
BEGIN
|
173
|
+
END
|
174
|
+
TAGS
|
175
|
+
INSTRUCTIONS
|
176
|
+
EXPORTS
|
177
|
+
IMPORTS
|
178
|
+
EXTENSIBILITY
|
179
|
+
IMPLIED
|
180
|
+
AUTOMATIC
|
181
|
+
TYPEREF "typereference"
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
%%
|
186
|
+
|
187
|
+
Top:
|
188
|
+
{
|
189
|
+
*tree = rb_ary_new();
|
190
|
+
}
|
191
|
+
AssignmentList
|
192
|
+
{
|
193
|
+
*tree = $AssignmentList;
|
194
|
+
}
|
195
|
+
;
|
196
|
+
|
197
|
+
empty:
|
198
|
+
%empty
|
199
|
+
{
|
200
|
+
$$ = Qnil;
|
201
|
+
}
|
202
|
+
;
|
203
|
+
|
204
|
+
hstring: HSTRING;
|
205
|
+
|
206
|
+
bstring: BSTRING;
|
207
|
+
|
208
|
+
cstring: CSTRING;
|
209
|
+
|
210
|
+
identifier: ID;
|
211
|
+
|
212
|
+
typereference: TYPEREF;
|
213
|
+
|
214
|
+
modulereference: typereference;
|
215
|
+
|
216
|
+
valuereference: identifier;
|
217
|
+
|
218
|
+
number: POSINT | NEGINT;
|
219
|
+
|
220
|
+
encodingreference: identifier;
|
221
|
+
|
222
|
+
/**********************************************************************/
|
223
|
+
|
224
|
+
AssignmentList:
|
225
|
+
AssignmentList[list] Assignment[item]
|
226
|
+
{
|
227
|
+
$$ = $list;
|
228
|
+
rb_ary_push($$, $item);
|
229
|
+
}
|
230
|
+
|
|
231
|
+
Assignment[item]
|
232
|
+
{
|
233
|
+
$$ = rb_ary_new3(1, $item);
|
234
|
+
}
|
235
|
+
;
|
236
|
+
|
237
|
+
Assignment:
|
238
|
+
TypeAssignment
|
239
|
+
|
|
240
|
+
ValueAssignment
|
241
|
+
;
|
242
|
+
|
243
|
+
TypeAssignment:
|
244
|
+
typereference[ref] ASSIGN optTypePrefix[tag] Type Constraint
|
245
|
+
{
|
246
|
+
$$ = $Type;
|
247
|
+
rb_hash_aset($$, ID2SYM(rb_intern("id")), $ref);
|
248
|
+
rb_hash_aset($$, ID2SYM(rb_intern("tag")), $tag);
|
249
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
250
|
+
rb_hash_aset($$, ID2SYM(rb_intern("constraint")), $Constraint);
|
251
|
+
}
|
252
|
+
;
|
253
|
+
|
254
|
+
ValueAssignment:
|
255
|
+
valuereference[ref] Type[gov] ASSIGN Value[value]
|
256
|
+
{
|
257
|
+
$$ = $value;
|
258
|
+
rb_hash_aset($$, ID2SYM(rb_intern("id")), $ref);
|
259
|
+
rb_hash_aset($$, ID2SYM(rb_intern("governor")), $gov);
|
260
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
261
|
+
}
|
262
|
+
;
|
263
|
+
|
264
|
+
/**********************************************************************/
|
265
|
+
|
266
|
+
Value:
|
267
|
+
BuiltinValue[value]
|
268
|
+
{
|
269
|
+
$$ = rb_hash_new();
|
270
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("BuiltinValue")));
|
271
|
+
rb_hash_aset($$, ID2SYM(rb_intern("value")), $value);
|
272
|
+
}
|
273
|
+
|
|
274
|
+
DefinedValue[value]
|
275
|
+
{
|
276
|
+
$$ = rb_hash_new();
|
277
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("DefinedValue")));
|
278
|
+
rb_hash_aset($$, ID2SYM(rb_intern("ref")), $value);
|
279
|
+
}
|
280
|
+
;
|
281
|
+
|
282
|
+
BuiltinValue:
|
283
|
+
TRUE
|
284
|
+
|
|
285
|
+
FALSE
|
286
|
+
|
|
287
|
+
NULL
|
288
|
+
|
|
289
|
+
POSINT
|
290
|
+
|
|
291
|
+
NEGINT
|
292
|
+
|
|
293
|
+
HEXINT
|
294
|
+
|
|
295
|
+
POSREAL
|
296
|
+
|
|
297
|
+
NEGREAL
|
298
|
+
|
|
299
|
+
PLUS_INFINITY
|
300
|
+
|
|
301
|
+
MINUS_INFINITY
|
302
|
+
|
|
303
|
+
NOT_A_NUMBER
|
304
|
+
;
|
305
|
+
|
306
|
+
DefinedValue:
|
307
|
+
valuereference
|
308
|
+
;
|
309
|
+
|
310
|
+
NamedValue:
|
311
|
+
identifier Value
|
312
|
+
{
|
313
|
+
$$ = rb_hash_new();
|
314
|
+
rb_hash_aset($$, ID2SYM(rb_intern("id")), $identifier);
|
315
|
+
rb_hash_aset($$, ID2SYM(rb_intern("value")), $Value);
|
316
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
317
|
+
}
|
318
|
+
;
|
319
|
+
|
320
|
+
/**********************************************************************/
|
321
|
+
|
322
|
+
Type:
|
323
|
+
BitStringType
|
324
|
+
|
|
325
|
+
BooleanType
|
326
|
+
|
|
327
|
+
CharacterStringType
|
328
|
+
|
|
329
|
+
ChoiceType
|
330
|
+
|
|
331
|
+
EnumeratedType
|
332
|
+
|
|
333
|
+
IntegerType
|
334
|
+
|
|
335
|
+
NullType
|
336
|
+
|
|
337
|
+
OctetStringType
|
338
|
+
|
|
339
|
+
RealType
|
340
|
+
|
|
341
|
+
SequenceOfType
|
342
|
+
|
|
343
|
+
SequenceType
|
344
|
+
|
|
345
|
+
DefinedType
|
346
|
+
;
|
347
|
+
|
348
|
+
/**********************************************************************/
|
349
|
+
|
350
|
+
CharacterStringType:
|
351
|
+
RestrictedCharacterStringType
|
352
|
+
|
|
353
|
+
UnrestrictedCharacterStringType
|
354
|
+
;
|
355
|
+
|
356
|
+
UnrestrictedCharacterStringType:
|
357
|
+
CHARACTER STRING
|
358
|
+
{
|
359
|
+
$$ = rb_hash_new();
|
360
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("CharacterString")));
|
361
|
+
}
|
362
|
+
;
|
363
|
+
|
364
|
+
RestrictedCharacterStringType:
|
365
|
+
BMPString
|
366
|
+
{
|
367
|
+
$$ = rb_hash_new();
|
368
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("BMPString")));
|
369
|
+
}
|
370
|
+
|
|
371
|
+
GeneralString
|
372
|
+
{
|
373
|
+
$$ = rb_hash_new();
|
374
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("GeneralString")));
|
375
|
+
}
|
376
|
+
|
|
377
|
+
GraphicString
|
378
|
+
{
|
379
|
+
$$ = rb_hash_new();
|
380
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("GraphicString")));
|
381
|
+
}
|
382
|
+
|
|
383
|
+
IA5String
|
384
|
+
{
|
385
|
+
$$ = rb_hash_new();
|
386
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("IA5String")));
|
387
|
+
}
|
388
|
+
|
|
389
|
+
ISO646String
|
390
|
+
{
|
391
|
+
$$ = rb_hash_new();
|
392
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("ISO646String")));
|
393
|
+
}
|
394
|
+
|
|
395
|
+
NumericString
|
396
|
+
{
|
397
|
+
$$ = rb_hash_new();
|
398
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("NumericString")));
|
399
|
+
}
|
400
|
+
|
|
401
|
+
PrintableString
|
402
|
+
{
|
403
|
+
$$ = rb_hash_new();
|
404
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("PrintableString")));
|
405
|
+
}
|
406
|
+
|
|
407
|
+
TeletexString
|
408
|
+
{
|
409
|
+
$$ = rb_hash_new();
|
410
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("TeletexString")));
|
411
|
+
}
|
412
|
+
|
|
413
|
+
T61String
|
414
|
+
{
|
415
|
+
$$ = rb_hash_new();
|
416
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("T61String")));
|
417
|
+
}
|
418
|
+
|
|
419
|
+
UniversalString
|
420
|
+
{
|
421
|
+
$$ = rb_hash_new();
|
422
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("UniversalString")));
|
423
|
+
}
|
424
|
+
|
|
425
|
+
UTF8String
|
426
|
+
{
|
427
|
+
$$ = rb_hash_new();
|
428
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("UTF8String")));
|
429
|
+
}
|
430
|
+
|
|
431
|
+
VideotexString
|
432
|
+
{
|
433
|
+
$$ = rb_hash_new();
|
434
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("VideotexString")));
|
435
|
+
}
|
436
|
+
|
|
437
|
+
VisibleString
|
438
|
+
{
|
439
|
+
$$ = rb_hash_new();
|
440
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("VisibleString")));
|
441
|
+
}
|
442
|
+
;
|
443
|
+
|
444
|
+
/**********************************************************************/
|
445
|
+
|
446
|
+
DefinedType:
|
447
|
+
typereference[ref]
|
448
|
+
{
|
449
|
+
$$ = rb_hash_new();
|
450
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("DefinedType")));
|
451
|
+
rb_hash_aset($$, ID2SYM(rb_intern("ref")), $ref);
|
452
|
+
}
|
453
|
+
;
|
454
|
+
|
455
|
+
/**********************************************************************/
|
456
|
+
|
457
|
+
BooleanType:
|
458
|
+
BOOLEAN
|
459
|
+
{
|
460
|
+
$$ = rb_hash_new();
|
461
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("BOOLEAN")));
|
462
|
+
}
|
463
|
+
;
|
464
|
+
|
465
|
+
/**********************************************************************/
|
466
|
+
|
467
|
+
IntegerType:
|
468
|
+
INTEGER
|
469
|
+
{
|
470
|
+
$$ = rb_hash_new();
|
471
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("INTEGER")));
|
472
|
+
}
|
473
|
+
|
|
474
|
+
INTEGER '{' NamedNumberList '}'
|
475
|
+
{
|
476
|
+
$$ = rb_hash_new();
|
477
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("INTEGER")));
|
478
|
+
rb_hash_aset($$, ID2SYM(rb_intern("numberList")), $NamedNumberList);
|
479
|
+
}
|
480
|
+
;
|
481
|
+
|
482
|
+
NamedNumberList:
|
483
|
+
NamedNumber
|
484
|
+
{
|
485
|
+
$$ = rb_ary_new();
|
486
|
+
rb_ary_push($$, $NamedNumber);
|
487
|
+
}
|
488
|
+
|
|
489
|
+
NamedNumberList ',' NamedNumber
|
490
|
+
{
|
491
|
+
rb_ary_push($$, $NamedNumber);
|
492
|
+
}
|
493
|
+
;
|
494
|
+
|
495
|
+
NamedNumber:
|
496
|
+
identifier[id] '(' NamedNumberNumber[number] ')'
|
497
|
+
{
|
498
|
+
$$ = rb_hash_new();
|
499
|
+
rb_hash_aset($$, ID2SYM(rb_intern("id")), $id);
|
500
|
+
rb_hash_aset($$, ID2SYM(rb_intern("number")), $number);
|
501
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
502
|
+
}
|
503
|
+
;
|
504
|
+
|
505
|
+
NamedNumberNumber:
|
506
|
+
DefinedValue
|
507
|
+
|
|
508
|
+
SignedNumber
|
509
|
+
;
|
510
|
+
|
511
|
+
SignedNumber:
|
512
|
+
POSINT
|
513
|
+
|
|
514
|
+
NEGINT
|
515
|
+
;
|
516
|
+
|
517
|
+
/**********************************************************************/
|
518
|
+
|
519
|
+
EnumeratedType:
|
520
|
+
ENUMERATED '{' EnumerationItem[item] NextEnumerationItem[list]
|
521
|
+
{
|
522
|
+
$$ = $list;
|
523
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("ENUMERATED")));
|
524
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("root"))), $item);
|
525
|
+
}
|
526
|
+
;
|
527
|
+
|
528
|
+
NextEnumerationItem:
|
529
|
+
'}'
|
530
|
+
{
|
531
|
+
$$ = rb_hash_new();
|
532
|
+
rb_hash_aset($$, ID2SYM(rb_intern("root")), rb_ary_new());
|
533
|
+
}
|
534
|
+
|
|
535
|
+
',' EnumerationItem[item] NextEnumerationItem[list]
|
536
|
+
{
|
537
|
+
$$ = $list;
|
538
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("root"))), $item);
|
539
|
+
}
|
540
|
+
|
|
541
|
+
',' ELLIPSES ExceptionSpec NextAddEnumerationItem[list]
|
542
|
+
{
|
543
|
+
$$ = $list;
|
544
|
+
rb_hash_aset($$, ID2SYM(rb_intern("extensible")), Qtrue);
|
545
|
+
rb_hash_aset($$, ID2SYM(rb_intern("exceptionSpec")), $ExceptionSpec);
|
546
|
+
}
|
547
|
+
;
|
548
|
+
|
549
|
+
NextAddEnumerationItem:
|
550
|
+
'}'
|
551
|
+
{
|
552
|
+
$$ = rb_hash_new();
|
553
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), rb_ary_new());
|
554
|
+
rb_hash_aset($$, ID2SYM(rb_intern("root")), rb_ary_new());
|
555
|
+
}
|
556
|
+
|
|
557
|
+
',' EnumerationItem[item] NextAddEnumerationItem[list]
|
558
|
+
{
|
559
|
+
$$ = $list;
|
560
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("additional"))), $item);
|
561
|
+
}
|
562
|
+
;
|
563
|
+
|
564
|
+
EnumerationItem:
|
565
|
+
identifier
|
566
|
+
{
|
567
|
+
$$ = rb_hash_new();
|
568
|
+
rb_hash_aset($$, ID2SYM(rb_intern("id")), $identifier);
|
569
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
570
|
+
}
|
571
|
+
|
|
572
|
+
NamedNumber
|
573
|
+
;
|
574
|
+
|
575
|
+
/**********************************************************************/
|
576
|
+
|
577
|
+
RealType:
|
578
|
+
REAL
|
579
|
+
{
|
580
|
+
$$ = rb_hash_new();
|
581
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("REAL")));
|
582
|
+
}
|
583
|
+
;
|
584
|
+
|
585
|
+
/**********************************************************************/
|
586
|
+
|
587
|
+
BitStringType:
|
588
|
+
BIT STRING
|
589
|
+
{
|
590
|
+
$$ = rb_hash_new();
|
591
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("BITSTRING")));
|
592
|
+
rb_hash_aset($$, ID2SYM(rb_intern("bitList")), rb_ary_new());
|
593
|
+
}
|
594
|
+
|
|
595
|
+
BIT STRING '{' NamedNumberList '}'
|
596
|
+
{
|
597
|
+
$$ = rb_hash_new();
|
598
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("BITSTRING")));
|
599
|
+
rb_hash_aset($$, ID2SYM(rb_intern("bitList")), $NamedNumberList);
|
600
|
+
}
|
601
|
+
;
|
602
|
+
|
603
|
+
/**********************************************************************/
|
604
|
+
|
605
|
+
OctetStringType:
|
606
|
+
OCTET STRING
|
607
|
+
{
|
608
|
+
$$ = rb_hash_new();
|
609
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("OCTETSTRING")));
|
610
|
+
}
|
611
|
+
;
|
612
|
+
|
613
|
+
/**********************************************************************/
|
614
|
+
|
615
|
+
NullType:
|
616
|
+
NULL
|
617
|
+
{
|
618
|
+
$$ = rb_hash_new();
|
619
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("NULL")));
|
620
|
+
}
|
621
|
+
;
|
622
|
+
|
623
|
+
/**********************************************************************/
|
624
|
+
|
625
|
+
SequenceType:
|
626
|
+
SEQUENCE '{' HeadComponentTypeList[list]
|
627
|
+
{
|
628
|
+
$$ = $list;
|
629
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("SEQUENCE")));
|
630
|
+
}
|
631
|
+
;
|
632
|
+
|
633
|
+
HeadComponentTypeList:
|
634
|
+
'}'
|
635
|
+
{
|
636
|
+
$$ = rb_hash_new();
|
637
|
+
}
|
638
|
+
|
|
639
|
+
ELLIPSES ExceptionSpec AdditionalComponentTypeList[list]
|
640
|
+
{
|
641
|
+
$$ = $list;
|
642
|
+
rb_hash_aset($$, ID2SYM(rb_intern("extensible")), Qtrue);
|
643
|
+
rb_hash_aset($$, ID2SYM(rb_intern("exceptionSpec")), $ExceptionSpec);
|
644
|
+
}
|
645
|
+
|
|
646
|
+
ComponentType[item] NextHeadComponentType[list]
|
647
|
+
{
|
648
|
+
$$ = $list;
|
649
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("head"))), $item);
|
650
|
+
}
|
651
|
+
;
|
652
|
+
|
653
|
+
NextHeadComponentType:
|
654
|
+
'}'
|
655
|
+
{
|
656
|
+
$$ = rb_hash_new();
|
657
|
+
rb_hash_aset($$, ID2SYM(rb_intern("head")), rb_ary_new());
|
658
|
+
}
|
659
|
+
|
|
660
|
+
',' ELLIPSES ExceptionSpec AdditionalComponentTypeList[list]
|
661
|
+
{
|
662
|
+
$$ = $list;
|
663
|
+
rb_hash_aset($$, ID2SYM(rb_intern("extensible")), Qtrue);
|
664
|
+
rb_hash_aset($$, ID2SYM(rb_intern("exceptionSpec")), $ExceptionSpec);
|
665
|
+
}
|
666
|
+
|
|
667
|
+
',' ComponentType[item] NextHeadComponentType[list]
|
668
|
+
{
|
669
|
+
$$ = $list;
|
670
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("head"))), $item);
|
671
|
+
}
|
672
|
+
;
|
673
|
+
|
674
|
+
AdditionalComponentTypeList:
|
675
|
+
'}'
|
676
|
+
{
|
677
|
+
$$ = rb_hash_new();
|
678
|
+
rb_hash_aset($$, ID2SYM(rb_intern("head")), rb_ary_new());
|
679
|
+
}
|
680
|
+
|
|
681
|
+
',' AdditionalComponentType[item] NextAdditionalComponentType[list]
|
682
|
+
{
|
683
|
+
$$ = $list;
|
684
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("additional"))), $item);
|
685
|
+
}
|
686
|
+
;
|
687
|
+
|
688
|
+
NextAdditionalComponentType:
|
689
|
+
'}'
|
690
|
+
{
|
691
|
+
$$ = rb_hash_new();
|
692
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), rb_ary_new());
|
693
|
+
rb_hash_aset($$, ID2SYM(rb_intern("head")), rb_ary_new());
|
694
|
+
}
|
695
|
+
|
|
696
|
+
',' ELLIPSES TailComponentTypeList[list] '}'
|
697
|
+
{
|
698
|
+
$$ = rb_hash_new();
|
699
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), rb_ary_new());
|
700
|
+
rb_hash_aset($$, ID2SYM(rb_intern("tail")), $list);
|
701
|
+
rb_hash_aset($$, ID2SYM(rb_intern("extensible")), Qtrue);
|
702
|
+
}
|
703
|
+
|
|
704
|
+
',' AdditionalComponentType[item] NextAdditionalComponentType[list]
|
705
|
+
{
|
706
|
+
$$ = $list;
|
707
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("additional"))), $item);
|
708
|
+
}
|
709
|
+
;
|
710
|
+
|
711
|
+
AdditionalComponentType:
|
712
|
+
ComponentType
|
713
|
+
|
|
714
|
+
LVERSION VersionNumber[version] ComponentTypeList[additional] RVERSION
|
715
|
+
{
|
716
|
+
$$ = rb_hash_new();
|
717
|
+
rb_hash_aset($$, ID2SYM(rb_intern("version")), $version);
|
718
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), $additional);
|
719
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
720
|
+
}
|
721
|
+
;
|
722
|
+
|
723
|
+
ComponentTypeList:
|
724
|
+
ComponentType
|
725
|
+
|
|
726
|
+
ComponentTypeList ',' ComponentType
|
727
|
+
;
|
728
|
+
|
729
|
+
TailComponentTypeList:
|
730
|
+
empty
|
731
|
+
|
|
732
|
+
',' ComponentTypeList[list]
|
733
|
+
{
|
734
|
+
$$ = $list;
|
735
|
+
}
|
736
|
+
;
|
737
|
+
|
738
|
+
VersionNumber:
|
739
|
+
empty
|
740
|
+
|
|
741
|
+
POSINT ':'
|
742
|
+
;
|
743
|
+
|
744
|
+
ComponentType:
|
745
|
+
NamedType
|
746
|
+
|
|
747
|
+
NamedType OPTIONAL
|
748
|
+
{
|
749
|
+
rb_hash_aset($$, ID2SYM(rb_intern("OPTIONAL")), Qtrue);
|
750
|
+
}
|
751
|
+
|
|
752
|
+
NamedType DEFAULT Value
|
753
|
+
{
|
754
|
+
rb_hash_aset($$, ID2SYM(rb_intern("DEFAULT")), $Value);
|
755
|
+
}
|
756
|
+
|
|
757
|
+
COMPONENTS OF Type
|
758
|
+
{
|
759
|
+
$$ = Qnil;
|
760
|
+
}
|
761
|
+
;
|
762
|
+
|
763
|
+
NamedType:
|
764
|
+
identifier optTypePrefix[tag] Type Constraint
|
765
|
+
{
|
766
|
+
$$ = $Type;
|
767
|
+
rb_hash_aset($$, ID2SYM(rb_intern("id")), $identifier);
|
768
|
+
rb_hash_aset($$, ID2SYM(rb_intern("tag")), $tag);
|
769
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
770
|
+
rb_hash_aset($$, ID2SYM(rb_intern("constraint")), $Constraint);
|
771
|
+
}
|
772
|
+
;
|
773
|
+
|
774
|
+
|
775
|
+
/**********************************************************************/
|
776
|
+
|
777
|
+
SequenceOfType:
|
778
|
+
SEQUENCE SequenceOfTypeVariant SequenceOfTypeTarget
|
779
|
+
{
|
780
|
+
$$ = $SequenceOfTypeVariant;
|
781
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("SEQUENCEOF")));
|
782
|
+
rb_hash_aset($$, ID2SYM(rb_intern("type")), $SequenceOfTypeTarget);
|
783
|
+
}
|
784
|
+
|
785
|
+
SequenceOfTypeVariant:
|
786
|
+
OF
|
787
|
+
{
|
788
|
+
$$ = rb_hash_new();
|
789
|
+
}
|
790
|
+
|
|
791
|
+
Constraint OF
|
792
|
+
{
|
793
|
+
$$ = rb_hash_new();
|
794
|
+
rb_hash_aset($$, ID2SYM(rb_intern("constraint")), $Constraint);
|
795
|
+
}
|
796
|
+
|
|
797
|
+
SizeConstraint OF
|
798
|
+
{
|
799
|
+
$$ = rb_hash_new();
|
800
|
+
rb_hash_aset($$, ID2SYM(rb_intern("constraint")), $SizeConstraint);
|
801
|
+
}
|
802
|
+
;
|
803
|
+
|
804
|
+
SequenceOfTypeTarget:
|
805
|
+
Type
|
806
|
+
|
|
807
|
+
NamedType
|
808
|
+
;
|
809
|
+
|
810
|
+
/**********************************************************************/
|
811
|
+
|
812
|
+
|
813
|
+
ChoiceType:
|
814
|
+
CHOICE '{' NamedType[item] NextAltType[list]
|
815
|
+
{
|
816
|
+
$$ = $list;
|
817
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("CHOICE")));
|
818
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("root"))), $item);
|
819
|
+
}
|
820
|
+
;
|
821
|
+
|
822
|
+
NextAltType:
|
823
|
+
'}'
|
824
|
+
{
|
825
|
+
$$ = rb_hash_new();
|
826
|
+
rb_hash_aset($$, ID2SYM(rb_intern("root")), rb_ary_new());
|
827
|
+
}
|
828
|
+
|
|
829
|
+
',' ELLIPSES ExceptionSpec NextAddAltType[list]
|
830
|
+
{
|
831
|
+
$$ = $list;
|
832
|
+
rb_hash_aset($$, ID2SYM(rb_intern("extensible")), Qtrue);
|
833
|
+
rb_hash_aset($$, ID2SYM(rb_intern("exceptionSpec")), $ExceptionSpec);
|
834
|
+
rb_hash_aset($$, ID2SYM(rb_intern("root")), rb_ary_new());
|
835
|
+
}
|
836
|
+
|
|
837
|
+
',' NamedType[item] NextAltType[list]
|
838
|
+
{
|
839
|
+
$$ = $list;
|
840
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("root"))), $item);
|
841
|
+
}
|
842
|
+
;
|
843
|
+
|
844
|
+
NextAddAltType:
|
845
|
+
'}'
|
846
|
+
{
|
847
|
+
$$ = rb_hash_new();
|
848
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), rb_ary_new());
|
849
|
+
}
|
850
|
+
|
|
851
|
+
',' ELLIPSES '}'
|
852
|
+
{
|
853
|
+
$$ = rb_hash_new();
|
854
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), rb_ary_new());
|
855
|
+
}
|
856
|
+
|
|
857
|
+
',' AddAltType[item] NextAddAltType[list]
|
858
|
+
{
|
859
|
+
$$ = $list;
|
860
|
+
rb_ary_unshift(rb_hash_aref($$, ID2SYM(rb_intern("additional"))), $item);
|
861
|
+
}
|
862
|
+
;
|
863
|
+
|
864
|
+
AddAltType:
|
865
|
+
NamedType
|
866
|
+
|
|
867
|
+
LVERSION VersionNumber[version] VersionedAltType[list] RVERSION
|
868
|
+
{
|
869
|
+
$$ = rb_hash_new();
|
870
|
+
rb_hash_aset($$, ID2SYM(rb_intern("version")), $version);
|
871
|
+
rb_hash_aset($$, ID2SYM(rb_intern("additional")), $list);
|
872
|
+
}
|
873
|
+
;
|
874
|
+
|
875
|
+
VersionedAltType:
|
876
|
+
VersionedAltType[list] ',' NamedType[item]
|
877
|
+
{
|
878
|
+
rb_ary_push($$, $item);
|
879
|
+
}
|
880
|
+
|
|
881
|
+
NamedType[item]
|
882
|
+
{
|
883
|
+
$$ = rb_ary_new3(1, $item);
|
884
|
+
}
|
885
|
+
;
|
886
|
+
|
887
|
+
/**********************************************************************/
|
888
|
+
|
889
|
+
optTypePrefix:
|
890
|
+
empty
|
891
|
+
|
|
892
|
+
TypePrefix
|
893
|
+
;
|
894
|
+
|
895
|
+
TypePrefix:
|
896
|
+
Tag
|
897
|
+
|
|
898
|
+
Tag IMPLICIT
|
899
|
+
{
|
900
|
+
$$ = $Tag;
|
901
|
+
rb_hash_aset($Tag, ID2SYM(rb_intern("type")), ID2SYM(rb_intern("Implicit")));
|
902
|
+
}
|
903
|
+
|
|
904
|
+
Tag EXPLICIT
|
905
|
+
{
|
906
|
+
$$ = $Tag;
|
907
|
+
rb_hash_aset($Tag, ID2SYM(rb_intern("type")), ID2SYM(rb_intern("Explicit")));
|
908
|
+
}
|
909
|
+
;
|
910
|
+
|
911
|
+
Tag:
|
912
|
+
'[' encodingreference ':' Class ']'
|
913
|
+
{
|
914
|
+
$$ = $Class;
|
915
|
+
}
|
916
|
+
|
|
917
|
+
'[' Class ']'
|
918
|
+
{
|
919
|
+
$$ = $Class;
|
920
|
+
}
|
921
|
+
;
|
922
|
+
|
923
|
+
Class:
|
924
|
+
UNIVERSAL ClassNumber
|
925
|
+
{
|
926
|
+
$$ = rb_hash_new();
|
927
|
+
rb_hash_aset($$, ID2SYM(rb_intern("classNumber")), $ClassNumber);
|
928
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("Universal")));
|
929
|
+
}
|
930
|
+
|
|
931
|
+
APPLICATION ClassNumber
|
932
|
+
{
|
933
|
+
$$ = rb_hash_new();
|
934
|
+
rb_hash_aset($$, ID2SYM(rb_intern("classNumber")), $ClassNumber);
|
935
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("Application")));
|
936
|
+
}
|
937
|
+
|
|
938
|
+
PRIVATE ClassNumber
|
939
|
+
{
|
940
|
+
$$ = rb_hash_new();
|
941
|
+
rb_hash_aset($$, ID2SYM(rb_intern("classNumber")), $ClassNumber);
|
942
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("Private")));
|
943
|
+
}
|
944
|
+
|
|
945
|
+
ClassNumber
|
946
|
+
{
|
947
|
+
$$ = rb_hash_new();
|
948
|
+
rb_hash_aset($$, ID2SYM(rb_intern("classNumber")), $ClassNumber);
|
949
|
+
}
|
950
|
+
;
|
951
|
+
|
952
|
+
ClassNumber:
|
953
|
+
number
|
954
|
+
|
|
955
|
+
DefinedValue
|
956
|
+
;
|
957
|
+
|
958
|
+
|
959
|
+
/**********************************************************************/
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
Constraint:
|
964
|
+
'(' ConstraintSpec ')'
|
965
|
+
{
|
966
|
+
$$ = $ConstraintSpec;
|
967
|
+
}
|
968
|
+
|
|
969
|
+
empty
|
970
|
+
;
|
971
|
+
|
972
|
+
ConstraintSpec:
|
973
|
+
ElementSetSpec
|
974
|
+
{
|
975
|
+
$$ = rb_hash_new();
|
976
|
+
rb_hash_aset($$, ID2SYM(rb_intern("rootElementSetSpec")), $ElementSetSpec);
|
977
|
+
}
|
978
|
+
;
|
979
|
+
|
980
|
+
ElementSetSpec:
|
981
|
+
ALL EXCEPT Elements
|
982
|
+
{
|
983
|
+
$$ = rb_ary_new();
|
984
|
+
rb_ary_push($$, ID2SYM(rb_intern("ALL")));
|
985
|
+
rb_ary_push($$, ID2SYM(rb_intern("EXCEPT")));
|
986
|
+
rb_ary_push($$, $Elements);
|
987
|
+
}
|
988
|
+
|
|
989
|
+
Elements NextElements
|
990
|
+
{
|
991
|
+
$$ = $NextElements;
|
992
|
+
rb_ary_unshift($$, $Elements);
|
993
|
+
}
|
994
|
+
;
|
995
|
+
|
996
|
+
NextElements:
|
997
|
+
UnionMark Elements NextElements[next]
|
998
|
+
{
|
999
|
+
rb_ary_unshift($next, $Elements);
|
1000
|
+
VALUE mark = rb_hash_new();
|
1001
|
+
rb_hash_aset(mark, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("UNION")));
|
1002
|
+
rb_hash_aset(mark, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
1003
|
+
rb_ary_unshift($$, mark);
|
1004
|
+
}
|
1005
|
+
|
|
1006
|
+
IntersectionMark Elements NextElements[next]
|
1007
|
+
{
|
1008
|
+
rb_ary_unshift($next, $Elements);
|
1009
|
+
VALUE mark = rb_hash_new();
|
1010
|
+
rb_hash_aset(mark, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("INTERSECTION")));
|
1011
|
+
rb_hash_aset(mark, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
1012
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
1013
|
+
rb_ary_unshift($$, mark);
|
1014
|
+
}
|
1015
|
+
|
|
1016
|
+
empty
|
1017
|
+
{
|
1018
|
+
$$ = rb_ary_new();
|
1019
|
+
}
|
1020
|
+
;
|
1021
|
+
|
1022
|
+
IntersectionMark:
|
1023
|
+
INTERSECTION
|
1024
|
+
|
|
1025
|
+
'^'
|
1026
|
+
;
|
1027
|
+
|
1028
|
+
UnionMark:
|
1029
|
+
UNION
|
1030
|
+
|
|
1031
|
+
'|'
|
1032
|
+
;
|
1033
|
+
|
1034
|
+
Elements:
|
1035
|
+
'(' ElementSetSpec ')'
|
1036
|
+
|
|
1037
|
+
SubTypeElements
|
1038
|
+
;
|
1039
|
+
|
1040
|
+
SubTypeElements:
|
1041
|
+
SingleValue
|
1042
|
+
|
|
1043
|
+
ValueRange
|
1044
|
+
|
|
1045
|
+
SizeConstraint
|
1046
|
+
;
|
1047
|
+
|
1048
|
+
SingleValue:
|
1049
|
+
Value
|
1050
|
+
{
|
1051
|
+
$$ = rb_hash_new();
|
1052
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("SingleValue")));
|
1053
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
1054
|
+
rb_hash_aset($$, ID2SYM(rb_intern("value")), $Value);
|
1055
|
+
}
|
1056
|
+
;
|
1057
|
+
|
1058
|
+
ValueRange:
|
1059
|
+
LowerEndpoint RANGE UpperEndpoint
|
1060
|
+
{
|
1061
|
+
$$ = rb_hash_new();
|
1062
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("ValueRange")));
|
1063
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
1064
|
+
rb_hash_aset($$, ID2SYM(rb_intern("lower")), $LowerEndpoint);
|
1065
|
+
rb_hash_aset($$, ID2SYM(rb_intern("upper")), $UpperEndpoint);
|
1066
|
+
}
|
1067
|
+
;
|
1068
|
+
|
1069
|
+
LowerEndpoint:
|
1070
|
+
LowerEndValue
|
1071
|
+
|
|
1072
|
+
LowerEndValue '<'
|
1073
|
+
;
|
1074
|
+
|
1075
|
+
UpperEndpoint:
|
1076
|
+
UpperEndValue
|
1077
|
+
|
|
1078
|
+
'<' UpperEndValue
|
1079
|
+
{
|
1080
|
+
$$ = $UpperEndValue;
|
1081
|
+
}
|
1082
|
+
;
|
1083
|
+
|
1084
|
+
LowerEndValue:
|
1085
|
+
Value
|
1086
|
+
|
|
1087
|
+
MIN
|
1088
|
+
{
|
1089
|
+
$$ = ID2SYM(rb_intern("MIN"));
|
1090
|
+
}
|
1091
|
+
;
|
1092
|
+
|
1093
|
+
UpperEndValue:
|
1094
|
+
Value
|
1095
|
+
|
|
1096
|
+
MAX
|
1097
|
+
{
|
1098
|
+
$$ = ID2SYM(rb_intern("MAX"));
|
1099
|
+
}
|
1100
|
+
;
|
1101
|
+
|
1102
|
+
SizeConstraint:
|
1103
|
+
SIZE Constraint
|
1104
|
+
{
|
1105
|
+
$$ = rb_hash_new();
|
1106
|
+
rb_hash_aset($$, ID2SYM(rb_intern("class")), ID2SYM(rb_intern("SizeConstraint")));
|
1107
|
+
rb_hash_aset($$, ID2SYM(rb_intern("location")), newLocation(filename, &@$));
|
1108
|
+
rb_hash_aset($$, ID2SYM(rb_intern("constraint")), $Constraint);
|
1109
|
+
}
|
1110
|
+
;
|
1111
|
+
|
1112
|
+
|
1113
|
+
/**********************************************************************/
|
1114
|
+
|
1115
|
+
ExceptionSpec:
|
1116
|
+
'!' ExceptionIdentification
|
1117
|
+
|
|
1118
|
+
empty
|
1119
|
+
;
|
1120
|
+
|
1121
|
+
ExceptionIdentification:
|
1122
|
+
Type ':' Value
|
1123
|
+
|
|
1124
|
+
DefinedValue
|
1125
|
+
|
|
1126
|
+
SignedNumber
|
1127
|
+
;
|
1128
|
+
|
1129
|
+
%%
|
1130
|
+
|
1131
|
+
|
1132
|
+
|
1133
|
+
/* public functions ***************************************************/
|
1134
|
+
|
1135
|
+
void Init_ext_parser(void)
|
1136
|
+
{
|
1137
|
+
ASN = rb_define_module_under(rb_define_module("RetroIDL"), "ASN");
|
1138
|
+
rb_define_module_function(ASN, "parseFileBuffer", parseFileBuffer, 1);
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
void yyerror(YYLTYPE *locp, yyscan_t scanner, VALUE filename, VALUE *tree, char const *msg, ... )
|
1142
|
+
{
|
1143
|
+
int retval;
|
1144
|
+
VALUE rbString;
|
1145
|
+
char error[500];
|
1146
|
+
|
1147
|
+
int hdrLen;
|
1148
|
+
|
1149
|
+
hdrLen = snprintf(error, sizeof(error), "%s:%i:%i: error: ", (const char *)RSTRING_PTR(filename), locp->first_line, locp->first_column);
|
1150
|
+
|
1151
|
+
if((hdrLen > 0) && (hdrLen <= sizeof(error))){
|
1152
|
+
|
1153
|
+
va_list argptr;
|
1154
|
+
va_start(argptr, msg);
|
1155
|
+
retval = vsnprintf(&error[hdrLen], sizeof(error) - hdrLen, msg, argptr);
|
1156
|
+
va_end(argptr);
|
1157
|
+
|
1158
|
+
if((retval > 0) && ((hdrLen + retval) <= sizeof(error))){
|
1159
|
+
|
1160
|
+
rbString = rb_str_new((const char *)error, (hdrLen + retval));
|
1161
|
+
rb_io_puts(1, &rbString, rb_stderr);
|
1162
|
+
}
|
1163
|
+
else{
|
1164
|
+
|
1165
|
+
rb_bug("yyerror buffer is too short to contain error message");
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
else{
|
1169
|
+
|
1170
|
+
rb_bug("yyerror buffer is too short to contain error message");
|
1171
|
+
}
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
/* static functions ***************************************************/
|
1175
|
+
|
1176
|
+
static VALUE parseFileBuffer(VALUE self, VALUE attr)
|
1177
|
+
{
|
1178
|
+
yyscan_t scanner;
|
1179
|
+
|
1180
|
+
VALUE tree = Qnil;
|
1181
|
+
|
1182
|
+
VALUE buffer = rb_hash_aref(attr, ID2SYM(rb_intern("buffer")));
|
1183
|
+
VALUE filename = rb_hash_aref(attr, ID2SYM(rb_intern("fileName")));
|
1184
|
+
|
1185
|
+
if(yylex_init(&scanner) == 0){
|
1186
|
+
|
1187
|
+
if(yy_scan_bytes((const char *)RSTRING_PTR(buffer), RSTRING_LEN(buffer), scanner)){
|
1188
|
+
|
1189
|
+
yyparse(scanner, filename, &tree);
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
yylex_destroy(scanner);
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
return tree;
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
static VALUE newLocation(VALUE filename, YYLTYPE *location)
|
1199
|
+
{
|
1200
|
+
return rb_funcall(rb_const_get(ASN, rb_intern("Location")), rb_intern("new"), 5,
|
1201
|
+
filename,
|
1202
|
+
INT2NUM(location->first_line),
|
1203
|
+
INT2NUM(location->last_line),
|
1204
|
+
INT2NUM(location->first_column),
|
1205
|
+
INT2NUM(location->last_column)
|
1206
|
+
);
|
1207
|
+
}
|