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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 009d7c01b2c6814dd0bcf094f609bf7b79424a4c
4
+ data.tar.gz: a3b6a21878c4f4bdac68fe0e59b07db68d4451c8
5
+ SHA512:
6
+ metadata.gz: 00dc936dd53d71947c04ce5a58ea0db7986d5df6f3d850bfce418e5d6231269bbc85b4e9f82f60784b14189d272f4f52014be796da7538655ae63589c5a5bab5
7
+ data.tar.gz: 8ead1a976c35fe1bd3a1f09b1fe72c830191c278f1fc910d3872db9d153e51a15717b8f184c905e724ca0fd190c6ec55cd86afa92154043b34c525cb392991c1
@@ -0,0 +1,27 @@
1
+ #ifndef EXT_COMMON_H
2
+ #define EXT_COMMON_H
3
+
4
+ /* Value type. */
5
+ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
6
+ #include <ruby.h>
7
+ typedef VALUE YYSTYPE;
8
+ # define YYSTYPE_IS_TRIVIAL 1
9
+ # define YYSTYPE_IS_DECLARED 1
10
+ #endif
11
+
12
+ /* Location type. */
13
+ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
14
+ typedef struct YYLTYPE YYLTYPE;
15
+ struct YYLTYPE
16
+ {
17
+ int first_line;
18
+ int first_column;
19
+ int last_line;
20
+ int last_column;
21
+ };
22
+ # define YYLTYPE_IS_DECLARED 1
23
+ # define YYLTYPE_IS_TRIVIAL 1
24
+ #endif
25
+
26
+
27
+ #endif
@@ -0,0 +1,201 @@
1
+ /* Flex Configuration */
2
+ %{
3
+
4
+ /* includes ***********************************************************/
5
+
6
+ #include <float.h>
7
+ #include <ruby.h>
8
+ #include "parser.h"
9
+
10
+ /* static prototypes **************************************************/
11
+
12
+ /**
13
+ * - Inserted into lexer as part of the YY_USER_ACTION macro
14
+ * -
15
+ *
16
+ * @param[in] loc pointer to Bison location record
17
+ * @param[in] text
18
+ * @param[in] textLen length of text in bytes
19
+ *
20
+ * */
21
+ static void updateLocation(YYLTYPE *loc, const char *text, int textLen);
22
+
23
+ /* macros *************************************************************/
24
+
25
+ #define YY_USER_ACTION updateLocation(yylloc, yytext, yyleng);
26
+
27
+ /* generated **********************************************************/
28
+
29
+ %}
30
+
31
+ %top{
32
+
33
+ #include "ext_common.h"
34
+
35
+ }
36
+
37
+ %option nounput
38
+ %option noinput
39
+ %option bison-bridge bison-locations
40
+ %option reentrant
41
+ %option noyywrap
42
+
43
+ %x BLOCK_COMMENT
44
+
45
+ %%
46
+
47
+ "/*" { BEGIN(BLOCK_COMMENT); }
48
+ <BLOCK_COMMENT>"*/" { BEGIN(INITIAL); }
49
+ <BLOCK_COMMENT>. { }
50
+
51
+ "--"[^\r\n]* { /* skip comments */ }
52
+
53
+ "[" |
54
+ "]" |
55
+ "(" |
56
+ ")" |
57
+ "{" |
58
+ "}" |
59
+ "," |
60
+ "|" |
61
+ "^" |
62
+ "!" |
63
+ "<" |
64
+ ">" |
65
+ ":" |
66
+ ";" |
67
+ "\"" |
68
+ "/" { return *yytext; }
69
+
70
+ "[[" { return TOK_LVERSION; }
71
+ "]]" { *yylval = Qnil; return TOK_RVERSION; }
72
+ "::=" { return TOK_ASSIGN; }
73
+ ".." { return TOK_RANGE; }
74
+ "..." { return TOK_ELLIPSES; }
75
+
76
+
77
+ "DEFINITIONS" { return TOK_DEFINITIONS; }
78
+ "BEGIN" { return TOK_BEGIN; }
79
+ "END" { return TOK_END; }
80
+ "SET" { return TOK_SET; }
81
+ "NULL" { *yylval = Qnil; return TOK_NULL; }
82
+ "BOOLEAN" { return TOK_BOOLEAN; }
83
+ "INTEGER" { return TOK_INTEGER; }
84
+ "ENUMERATED" { return TOK_ENUMERATED; }
85
+ "REAL" { return TOK_REAL; }
86
+ "OCTET" { return TOK_OCTET; }
87
+ "CHARACTER" { return TOK_CHARACTER; }
88
+ "BIT" { return TOK_BIT; }
89
+ "STRING" { return TOK_STRING; }
90
+ "SIZE" { return TOK_SIZE; }
91
+ "CHOICE" { return TOK_CHOICE; }
92
+ "SEQUENCE" { return TOK_SEQUENCE; }
93
+ "OF" { return TOK_OF; }
94
+ "EXCEPT" { return TOK_EXCEPT; }
95
+ "INTERSECTION" { return TOK_INTERSECTION; }
96
+ "UNION" { return TOK_UNION; }
97
+ "ALL" { return TOK_ALL; }
98
+ "MIN" { return TOK_MIN; }
99
+ "MAX" { return TOK_MAX; }
100
+ "TRUE" { *yylval = Qtrue; return TOK_TRUE; }
101
+ "FALSE" { *yylval = Qfalse; return TOK_FALSE; }
102
+ "OPTIONAL" { return TOK_OPTIONAL; }
103
+ "DEFAULT" { return TOK_DEFAULT; }
104
+ "IMPLICIT" { return TOK_IMPLICIT; }
105
+ "EXPLICIT" { return TOK_EXPLICIT; }
106
+ "APPLICATION" { return TOK_APPLICATION; }
107
+ "PRIVATE" { return TOK_PRIVATE; }
108
+ "UNIVERSAL" { return TOK_UNIVERSAL; }
109
+
110
+ "DATE" { return TOK_DATE; }
111
+ "DATE-TIME" { return TOK_DATE_TIME; }
112
+ "DURATION" { return TOK_DURATION; }
113
+ "EMBEDDED" { return TOK_EMBEDDED; }
114
+ "PDV" { return TOK_PDV; }
115
+ "EXTERNAL" { return TOK_EXTERNAL; }
116
+ "RELATIVE-OID-IRI" { return TOK_RELATIVE_OID_IRI; }
117
+ "OBJECT" { return TOK_OBJECT; }
118
+ "IDENTIFIER" { return TOK_IDENTIFIER; }
119
+ "RELATIVE-IRI" { return TOK_RELATIVE_IRI; }
120
+ "RELATIVE-OID" { return TOK_RELATIVE_OID; }
121
+ "TIME" { return TOK_TIME; }
122
+ "TIME-OF-DAY" { return TOK_TIME_OF_DAY; }
123
+
124
+ "PLUS-INFINITY" { *yylval = rb_float_new(INFINITY); return TOK_PLUS_INFINITY; }
125
+ "MINUS-INFINITY" { *yylval = rb_float_new(-INFINITY); return TOK_MINUS_INFINITY; }
126
+ "NOT-A-NUMBER" { *yylval = rb_float_new(NAN); return TOK_NOT_A_NUMBER; }
127
+
128
+ "BMPString" { return TOK_BMPString; }
129
+ "GeneralString" { return TOK_GeneralString; }
130
+ "GraphicString" { return TOK_GraphicString; }
131
+ "IA5String" { return TOK_IA5String; }
132
+ "ISO646String" { return TOK_ISO646String; }
133
+ "NumericString" { return TOK_NumericString; }
134
+ "PrintableString" { return TOK_PrintableString; }
135
+ "TeletexString" { return TOK_TeletexString; }
136
+ "T61String" { return TOK_T61String; }
137
+ "UniversalString" { return TOK_UniversalString; }
138
+ "UTF8String" { return TOK_UTF8String; }
139
+ "VideotexString" { return TOK_VideotexString; }
140
+ "VisibleString" { return TOK_VisibleString; }
141
+
142
+ "CONTAINS" { return TOK_CONTAINS; }
143
+ "INCLUDES" { return TOK_INCLUDES; }
144
+ "FROM" { return TOK_FROM; }
145
+ "COMPONENT" { return TOK_COMPONENT; }
146
+ "COMPONENTS" { return TOK_COMPONENTS; }
147
+ "PRESENT" { return TOK_PRESENT; }
148
+ "ABSENT" { return TOK_ABSENT; }
149
+ "PATTERN" { return TOK_PATTERN; }
150
+ "SETTINGS" { return TOK_SETTINGS; }
151
+ "TAGS" { return TOK_TAGS; }
152
+ "INSTRUCTIONS" { return TOK_INSTRUCTIONS; }
153
+ "EXPORTS" { return TOK_EXPORTS; }
154
+ "IMPORTS" { return TOK_IMPORTS; }
155
+ "EXTENSIBILITY" { return TOK_EXTENSIBILITY; }
156
+ "IMPLIED" { return TOK_IMPLIED; }
157
+ "AUTOMATIC" { return TOK_AUTOMATIC; }
158
+
159
+ [ \t\n\r] ;
160
+
161
+ [0-9]+ { unsigned int tmp = 0; sscanf(yytext, "%u", &tmp); *yylval = UINT2NUM(tmp); return TOK_POSINT; }
162
+ [-][1-9][0-9]* { int tmp = 0; sscanf(yytext, "%i", &tmp); *yylval = INT2NUM(tmp); return TOK_NEGINT; }
163
+ [0][x][0-9a-fA-F]+ { unsigned int tmp = 0; sscanf(yytext, "%x", &tmp); *yylval = UINT2NUM(tmp); return TOK_HEXINT; }
164
+ [0-9]+\.[0-9]+ { float tmp = 0; sscanf(yytext, "%f", &tmp); *yylval = rb_float_new(tmp); return TOK_POSREAL; }
165
+ [-][1-9][0-9]*\.[0-9]+ { float tmp = 0; sscanf(yytext, "%f", &tmp); *yylval = rb_float_new(tmp); return TOK_NEGREAL; }
166
+
167
+ [a-z][a-zA-Z0-9_\-]* { *yylval = rb_str_new(yytext, yyleng); return TOK_ID; }
168
+
169
+ [A-Z][a-zA-Z0-9_\-]* { *yylval = rb_str_new(yytext, yyleng); return TOK_TYPEREF; }
170
+
171
+ ['][a-fA-F0-9]*['][H] { *yylval = rb_str_new(yytext, yyleng); return TOK_HSTRING; }
172
+ ['][0-1]*['][B] { *yylval = rb_str_new(yytext, yyleng); return TOK_BSTRING; }
173
+
174
+ L?H\"(\\.|[^\\"])*\" { *yylval = rb_str_new(yytext, yyleng); return TOK_CSTRING; }
175
+
176
+ . ;
177
+
178
+ %%
179
+
180
+ /* static functions ***************************************************/
181
+
182
+ static void updateLocation(YYLTYPE *loc, const char *text, int textLen)
183
+ {
184
+ int i;
185
+
186
+ loc->first_line = loc->last_line;
187
+ loc->first_column = loc->last_column;
188
+
189
+ for(i=0; i < textLen; i++){
190
+
191
+ if(text[i] == '\n'){
192
+
193
+ loc->last_line++;
194
+ loc->last_column = 0;
195
+ }
196
+ else{
197
+
198
+ loc->last_column++;
199
+ }
200
+ }
201
+ }