Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | %{ |
| 2 | |
| 3 | #include <stdlib.h> |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 6 | #include <stdarg.h> |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 7 | #include <errno.h> |
| 8 | #include <assert.h> |
| 9 | |
| 10 | #include "asn1parser.h" |
| 11 | |
| 12 | #define YYPARSE_PARAM param |
Lev Walkin | 4354b44 | 2005-06-07 21:25:42 +0000 | [diff] [blame] | 13 | #define YYPARSE_PARAM_TYPE void ** |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 14 | #define YYERROR_VERBOSE |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 15 | #define YYDEBUG 1 |
| 16 | #define YYFPRINTF prefixed_fprintf |
| 17 | |
| 18 | /* |
| 19 | * Prefix parser debug with "PARSER: " for easier human eye scanning. |
| 20 | */ |
| 21 | static int |
| 22 | __attribute__((format(printf, 2, 3))) |
| 23 | prefixed_fprintf(FILE *f, const char *fmt, ...) { |
| 24 | static int line_ended = 1; |
| 25 | va_list ap; |
| 26 | va_start(ap, fmt); |
| 27 | if(line_ended) { |
| 28 | fprintf(f, "PARSER: "); |
| 29 | line_ended = 0; |
| 30 | } |
| 31 | size_t len = strlen(fmt); |
| 32 | if(len && fmt[len-1] == '\n') { |
| 33 | line_ended = 1; |
| 34 | } |
| 35 | int ret = vfprintf(f, fmt, ap); |
| 36 | va_end(ap); |
| 37 | return ret; |
| 38 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 39 | |
| 40 | int yylex(void); |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 41 | static int yyerror(const char *msg); |
| 42 | |
Lev Walkin | 8daab91 | 2005-06-07 21:32:16 +0000 | [diff] [blame] | 43 | #ifdef YYBYACC |
| 44 | int yyparse(void **param); /* byacc does not produce a prototype */ |
| 45 | #endif |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 46 | void asn1p_lexer_hack_push_opaque_state(void); |
| 47 | void asn1p_lexer_hack_enable_with_syntax(void); |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 48 | void asn1p_lexer_hack_push_encoding_control(void); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 49 | #define yylineno asn1p_lineno |
| 50 | extern int asn1p_lineno; |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 51 | const char *asn1p_parse_debug_filename; |
| 52 | #define ASN_FILENAME asn1p_parse_debug_filename |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 53 | |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 54 | /* |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 55 | * Process directives as <ASN1C:RepresentAsPointer> |
Lev Walkin | 4696c74 | 2005-08-22 12:23:54 +0000 | [diff] [blame] | 56 | */ |
| 57 | extern int asn1p_as_pointer; |
Lev Walkin | 4696c74 | 2005-08-22 12:23:54 +0000 | [diff] [blame] | 58 | |
| 59 | /* |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 60 | * This temporary variable is used to solve the shortcomings of 1-lookahead |
| 61 | * parser. |
| 62 | */ |
| 63 | static struct AssignedIdentifier *saved_aid; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 64 | |
Lev Walkin | 2e9bd5c | 2005-08-13 09:07:11 +0000 | [diff] [blame] | 65 | static asn1p_value_t *_convert_bitstring2binary(char *str, int base); |
| 66 | static void _fixup_anonymous_identifier(asn1p_expr_t *expr); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 67 | |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 68 | static asn1p_module_t *currentModule; |
| 69 | #define NEW_EXPR() (asn1p_expr_new(yylineno, currentModule)) |
| 70 | |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 71 | #define checkmem(ptr) do { \ |
| 72 | if(!(ptr)) \ |
| 73 | return yyerror("Memory failure"); \ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 74 | } while(0) |
| 75 | |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 76 | #define CONSTRAINT_INSERT(root, constr_type, arg1, arg2) do { \ |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 77 | if(arg1->type != constr_type) { \ |
| 78 | int __ret; \ |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 79 | root = asn1p_constraint_new(yylineno, currentModule); \ |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 80 | checkmem(root); \ |
| 81 | root->type = constr_type; \ |
| 82 | __ret = asn1p_constraint_insert(root, \ |
| 83 | arg1); \ |
| 84 | checkmem(__ret == 0); \ |
| 85 | } else { \ |
| 86 | root = arg1; \ |
| 87 | } \ |
| 88 | if(arg2) { \ |
| 89 | int __ret \ |
| 90 | = asn1p_constraint_insert(root, arg2); \ |
| 91 | checkmem(__ret == 0); \ |
| 92 | } \ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 93 | } while(0) |
| 94 | |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 95 | #ifdef AL_IMPORT |
| 96 | #error AL_IMPORT DEFINED ELSEWHERE! |
| 97 | #endif |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 98 | #define AL_IMPORT(to, where, from, field) \ |
| 99 | do { \ |
| 100 | if(!(from)) break; \ |
| 101 | while(TQ_FIRST(&((from)->where))) { \ |
| 102 | TQ_ADD(&((to)->where), TQ_REMOVE(&((from)->where), field), field); \ |
| 103 | } \ |
| 104 | assert(TQ_FIRST(&((from)->where)) == 0); \ |
| 105 | } while(0) |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 106 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 107 | %} |
| 108 | |
| 109 | |
| 110 | /* |
| 111 | * Token value definition. |
| 112 | * a_*: ASN-specific types. |
| 113 | * tv_*: Locally meaningful types. |
| 114 | */ |
| 115 | %union { |
| 116 | asn1p_t *a_grammar; |
| 117 | asn1p_module_flags_e a_module_flags; |
| 118 | asn1p_module_t *a_module; |
| 119 | asn1p_expr_type_e a_type; /* ASN.1 Type */ |
| 120 | asn1p_expr_t *a_expr; /* Constructed collection */ |
| 121 | asn1p_constraint_t *a_constr; /* Constraint */ |
| 122 | enum asn1p_constraint_type_e a_ctype;/* Constraint type */ |
| 123 | asn1p_xports_t *a_xports; /* IMports/EXports */ |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 124 | struct AssignedIdentifier a_aid; /* Assigned Identifier */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 125 | asn1p_oid_t *a_oid; /* Object Identifier */ |
| 126 | asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ |
| 127 | struct asn1p_type_tag_s a_tag; /* A tag */ |
| 128 | asn1p_ref_t *a_ref; /* Reference to custom type */ |
| 129 | asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ |
| 130 | asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ |
| 131 | struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ |
| 132 | asn1p_value_t *a_value; /* Number, DefinedValue, etc */ |
| 133 | struct asn1p_param_s a_parg; /* A parameter argument */ |
| 134 | asn1p_paramlist_t *a_plist; /* A pargs list */ |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 135 | struct asn1p_expr_marker_s a_marker; /* OPTIONAL/DEFAULT */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 136 | enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 137 | asn1c_integer_t a_int; |
Lev Walkin | adf863f | 2006-09-05 16:18:34 +0000 | [diff] [blame] | 138 | double a_dbl; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 139 | char *tv_str; |
| 140 | struct { |
| 141 | char *buf; |
| 142 | int len; |
| 143 | } tv_opaque; |
| 144 | struct { |
| 145 | char *name; |
| 146 | struct asn1p_type_tag_s tag; |
| 147 | } tv_nametag; |
| 148 | }; |
| 149 | |
| 150 | /* |
| 151 | * Token types returned by scanner. |
| 152 | */ |
| 153 | %token TOK_PPEQ /* "::=", Pseudo Pascal EQuality */ |
Lev Walkin | 0e90aa0 | 2013-03-19 16:17:13 -0700 | [diff] [blame] | 154 | %token TOK_VBracketLeft TOK_VBracketRight /* "[[", "]]" */ |
Lev Walkin | 57074f1 | 2006-03-16 05:11:14 +0000 | [diff] [blame] | 155 | %token <tv_opaque> TOK_whitespace /* A span of whitespace */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 156 | %token <tv_opaque> TOK_opaque /* opaque data (driven from .y) */ |
| 157 | %token <tv_str> TOK_bstring |
| 158 | %token <tv_opaque> TOK_cstring |
| 159 | %token <tv_str> TOK_hstring |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 160 | %token <tv_str> TOK_identifier "identifier" |
| 161 | %token <a_int> TOK_number "number" |
| 162 | %token <a_int> TOK_number_negative "negative number" |
Lev Walkin | adf863f | 2006-09-05 16:18:34 +0000 | [diff] [blame] | 163 | %token <a_dbl> TOK_realnumber |
Lev Walkin | d9574ae | 2005-03-24 16:22:35 +0000 | [diff] [blame] | 164 | %token <a_int> TOK_tuple |
| 165 | %token <a_int> TOK_quadruple |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 166 | %token <tv_str> TOK_typereference |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 167 | %token <tv_str> TOK_capitalreference /* "CLASS1" */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 168 | %token <tv_str> TOK_typefieldreference /* "&Pork" */ |
| 169 | %token <tv_str> TOK_valuefieldreference /* "&id" */ |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 170 | %token <tv_str> TOK_Literal /* "BY" */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 171 | |
| 172 | /* |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 173 | * Tokens available with asn1p_lexer_hack_push_extended_values(). |
| 174 | */ |
| 175 | %token TOK_ExtValue_BIT_STRING |
| 176 | |
| 177 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 178 | * Token types representing ASN.1 standard keywords. |
| 179 | */ |
| 180 | %token TOK_ABSENT |
| 181 | %token TOK_ABSTRACT_SYNTAX |
| 182 | %token TOK_ALL |
| 183 | %token TOK_ANY |
| 184 | %token TOK_APPLICATION |
| 185 | %token TOK_AUTOMATIC |
| 186 | %token TOK_BEGIN |
| 187 | %token TOK_BIT |
| 188 | %token TOK_BMPString |
| 189 | %token TOK_BOOLEAN |
| 190 | %token TOK_BY |
| 191 | %token TOK_CHARACTER |
| 192 | %token TOK_CHOICE |
| 193 | %token TOK_CLASS |
| 194 | %token TOK_COMPONENT |
| 195 | %token TOK_COMPONENTS |
| 196 | %token TOK_CONSTRAINED |
| 197 | %token TOK_CONTAINING |
| 198 | %token TOK_DEFAULT |
| 199 | %token TOK_DEFINITIONS |
| 200 | %token TOK_DEFINED |
| 201 | %token TOK_EMBEDDED |
| 202 | %token TOK_ENCODED |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 203 | %token TOK_ENCODING_CONTROL |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 204 | %token TOK_END |
| 205 | %token TOK_ENUMERATED |
| 206 | %token TOK_EXPLICIT |
| 207 | %token TOK_EXPORTS |
| 208 | %token TOK_EXTENSIBILITY |
| 209 | %token TOK_EXTERNAL |
| 210 | %token TOK_FALSE |
| 211 | %token TOK_FROM |
| 212 | %token TOK_GeneralizedTime |
| 213 | %token TOK_GeneralString |
| 214 | %token TOK_GraphicString |
| 215 | %token TOK_IA5String |
| 216 | %token TOK_IDENTIFIER |
| 217 | %token TOK_IMPLICIT |
| 218 | %token TOK_IMPLIED |
| 219 | %token TOK_IMPORTS |
| 220 | %token TOK_INCLUDES |
| 221 | %token TOK_INSTANCE |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 222 | %token TOK_INSTRUCTIONS |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 223 | %token TOK_INTEGER |
| 224 | %token TOK_ISO646String |
| 225 | %token TOK_MAX |
| 226 | %token TOK_MIN |
| 227 | %token TOK_MINUS_INFINITY |
| 228 | %token TOK_NULL |
| 229 | %token TOK_NumericString |
| 230 | %token TOK_OBJECT |
| 231 | %token TOK_ObjectDescriptor |
| 232 | %token TOK_OCTET |
| 233 | %token TOK_OF |
| 234 | %token TOK_OPTIONAL |
| 235 | %token TOK_PATTERN |
| 236 | %token TOK_PDV |
| 237 | %token TOK_PLUS_INFINITY |
| 238 | %token TOK_PRESENT |
| 239 | %token TOK_PrintableString |
| 240 | %token TOK_PRIVATE |
| 241 | %token TOK_REAL |
| 242 | %token TOK_RELATIVE_OID |
| 243 | %token TOK_SEQUENCE |
| 244 | %token TOK_SET |
| 245 | %token TOK_SIZE |
| 246 | %token TOK_STRING |
| 247 | %token TOK_SYNTAX |
| 248 | %token TOK_T61String |
| 249 | %token TOK_TAGS |
| 250 | %token TOK_TeletexString |
| 251 | %token TOK_TRUE |
| 252 | %token TOK_TYPE_IDENTIFIER |
| 253 | %token TOK_UNIQUE |
| 254 | %token TOK_UNIVERSAL |
| 255 | %token TOK_UniversalString |
| 256 | %token TOK_UTCTime |
| 257 | %token TOK_UTF8String |
| 258 | %token TOK_VideotexString |
| 259 | %token TOK_VisibleString |
| 260 | %token TOK_WITH |
Lev Walkin | 752e973 | 2017-08-04 02:06:22 -0700 | [diff] [blame] | 261 | %token UTF8_BOM "UTF-8 byte order mark" |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 262 | |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 263 | %nonassoc TOK_EXCEPT |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 264 | %left '^' TOK_INTERSECTION |
| 265 | %left '|' TOK_UNION |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 266 | |
| 267 | /* Misc tags */ |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 268 | %token TOK_TwoDots ".." |
| 269 | %token TOK_ThreeDots "..." |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 270 | |
| 271 | |
| 272 | /* |
| 273 | * Types defined herein. |
| 274 | */ |
| 275 | %type <a_grammar> ModuleList |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 276 | %type <a_module> ModuleDefinition |
| 277 | %type <a_module> ModuleBody |
| 278 | %type <a_module> AssignmentList |
| 279 | %type <a_module> Assignment |
| 280 | %type <a_module> optModuleBody /* Optional */ |
| 281 | %type <a_module_flags> optModuleDefinitionFlags |
| 282 | %type <a_module_flags> ModuleDefinitionFlags /* Set of FL */ |
| 283 | %type <a_module_flags> ModuleDefinitionFlag /* Single FL */ |
| 284 | %type <a_module> optImports |
| 285 | %type <a_module> optExports |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 286 | %type <a_module> ImportsDefinition |
Lev Walkin | 4a4543f | 2006-10-13 12:37:39 +0000 | [diff] [blame] | 287 | %type <a_module> optImportsBundleSet |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 288 | %type <a_module> ImportsBundleSet |
| 289 | %type <a_xports> ImportsBundle |
| 290 | %type <a_xports> ImportsList |
| 291 | %type <a_xports> ExportsDefinition |
| 292 | %type <a_xports> ExportsBody |
| 293 | %type <a_expr> ImportsElement |
| 294 | %type <a_expr> ExportsElement |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 295 | %type <a_expr> ExtensionAndException |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 296 | %type <a_expr> Type |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 297 | %type <a_expr> TaggedType |
| 298 | %type <a_expr> MaybeIndirectTaggedType |
| 299 | %type <a_expr> UntaggedType |
| 300 | %type <a_expr> DefinedUntaggedType |
| 301 | %type <a_expr> ConcreteTypeDeclaration "concrete TypeDeclaration" |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 302 | %type <a_expr> TypeDeclaration |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 303 | %type <a_expr> MaybeIndirectTypeDeclaration |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 304 | %type <a_ref> ComplexTypeReference |
| 305 | %type <a_ref> ComplexTypeReferenceAmpList |
| 306 | %type <a_refcomp> ComplexTypeReferenceElement |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 307 | %type <a_refcomp> PrimitiveFieldReference |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 308 | %type <a_expr> FieldSpec |
| 309 | %type <a_ref> FieldName |
| 310 | %type <a_ref> DefinedObjectClass |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 311 | %type <a_expr> ClassField |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 312 | %type <a_expr> ObjectClass |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 313 | %type <a_expr> DataTypeReference /* Type1 ::= Type2 */ |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 314 | %type <a_expr> DefinedType |
Lev Walkin | 557f27d | 2006-03-21 07:46:48 +0000 | [diff] [blame] | 315 | %type <a_constr> ValueSet /* {a|b|c}*/ |
| 316 | %type <a_expr> ValueSetTypeAssignment /* Val INTEGER ::= {1|2} */ |
Lev Walkin | c6ab03c | 2006-10-21 05:54:49 +0000 | [diff] [blame] | 317 | %type <a_expr> ValueAssignment /* val INTEGER ::= 1*/ |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 318 | %type <a_value> Value |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 319 | %type <a_value> SimpleValue |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 320 | %type <a_value> DefinedValue |
| 321 | %type <a_value> SignedNumber |
Lev Walkin | adf863f | 2006-09-05 16:18:34 +0000 | [diff] [blame] | 322 | %type <a_value> RealValue |
Lev Walkin | 1c8d5aa | 2006-10-27 05:37:39 +0000 | [diff] [blame] | 323 | %type <a_value> BitStringValue |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 324 | %type <a_expr> optComponentTypeLists |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 325 | %type <a_expr> ComponentTypeLists |
| 326 | %type <a_expr> ComponentType |
| 327 | %type <a_expr> AlternativeTypeLists |
| 328 | %type <a_expr> AlternativeType |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 329 | %type <a_expr> UniverationList |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 330 | %type <a_expr> Enumerations |
| 331 | %type <a_expr> NamedBitList |
| 332 | %type <a_expr> NamedBit |
| 333 | %type <a_expr> NamedNumberList |
| 334 | %type <a_expr> NamedNumber |
| 335 | %type <a_expr> IdentifierList |
| 336 | %type <a_expr> IdentifierElement |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 337 | %type <a_expr> UniverationElement |
| 338 | %type <tv_str> TypeRefName |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 339 | %type <tv_str> Identifier |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 340 | %type <a_ref> IdentifierAsReference |
| 341 | %type <a_value> IdentifierAsValue |
Lev Walkin | 83cac2f | 2004-09-22 16:03:36 +0000 | [diff] [blame] | 342 | %type <tv_str> optIdentifier |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 343 | %type <a_parg> ParameterArgumentName |
| 344 | %type <a_plist> ParameterArgumentList |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 345 | %type <a_expr> ActualParameter |
| 346 | %type <a_expr> ActualParameterList |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 347 | %type <a_aid> AssignedIdentifier /* OID/DefinedValue */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 348 | %type <a_oid> ObjectIdentifier /* OID */ |
| 349 | %type <a_oid> optObjectIdentifier /* Optional OID */ |
| 350 | %type <a_oid> ObjectIdentifierBody |
| 351 | %type <a_oid_arc> ObjectIdentifierElement |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 352 | %type <a_expr> BuiltinType |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 353 | %type <a_type> BasicTypeId |
| 354 | %type <a_type> BasicTypeId_UniverationCompatible |
| 355 | %type <a_type> BasicString |
| 356 | %type <tv_opaque> Opaque |
Lev Walkin | bf97915 | 2017-09-07 23:36:11 -0700 | [diff] [blame] | 357 | %type <tv_opaque> OpaqueFirstToken |
Lev Walkin | c603f10 | 2005-01-23 09:51:44 +0000 | [diff] [blame] | 358 | %type <a_tag> Tag /* [UNIVERSAL 0] IMPLICIT */ |
| 359 | %type <a_tag> TagClass TagTypeValue TagPlicit |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 360 | %type <a_tag> optTag /* [UNIVERSAL 0] IMPLICIT */ |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 361 | %type <a_constr> optConstraint |
| 362 | %type <a_constr> optManyConstraints /* Only for Type */ |
| 363 | %type <a_constr> ManyConstraints |
| 364 | %type <a_constr> optSizeOrConstraint |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 365 | %type <a_constr> Constraint |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 366 | %type <a_constr> PermittedAlphabet |
| 367 | %type <a_constr> SizeConstraint |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 368 | %type <a_constr> SingleTypeConstraint |
| 369 | %type <a_constr> MultipleTypeConstraints |
| 370 | %type <a_constr> NamedConstraint |
| 371 | %type <a_constr> FullSpecification |
| 372 | %type <a_constr> PartialSpecification |
| 373 | %type <a_constr> TypeConstraints |
| 374 | %type <a_constr> ConstraintSpec |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 375 | %type <a_constr> SubtypeConstraint |
| 376 | %type <a_constr> GeneralConstraint |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 377 | %type <a_constr> ElementSetSpecs /* 1..2,...,3 */ |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 378 | %type <a_constr> ElementSetSpec /* 1..2 */ |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 379 | %type <a_constr> Unions |
| 380 | %type <a_constr> Intersections |
| 381 | %type <a_constr> IntersectionElements |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 382 | %type <a_constr> Elements |
| 383 | %type <a_constr> SubtypeElements /* 1..2 */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 384 | %type <a_constr> SimpleTableConstraint |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 385 | %type <a_constr> UserDefinedConstraint |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 386 | %type <a_constr> TableConstraint |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 387 | %type <a_constr> ContentsConstraint |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 388 | %type <a_constr> PatternConstraint |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 389 | %type <a_constr> InnerTypeConstraints |
| 390 | %type <a_constr> ValueRange |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 391 | %type <a_constr> ComponentRelationConstraint |
| 392 | %type <a_constr> AtNotationList |
| 393 | %type <a_ref> AtNotationElement |
Lev Walkin | ff7dd14 | 2005-03-20 12:58:00 +0000 | [diff] [blame] | 394 | %type <a_value> SingleValue |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 395 | %type <a_value> LowerEndValue |
| 396 | %type <a_value> UpperEndValue |
Lev Walkin | ff7dd14 | 2005-03-20 12:58:00 +0000 | [diff] [blame] | 397 | %type <a_value> ContainedSubtype |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 398 | %type <a_ctype> ConstraintRangeSpec |
Lev Walkin | 1e448d3 | 2005-03-24 14:26:38 +0000 | [diff] [blame] | 399 | %type <a_value> RestrictedCharacterStringValue |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 400 | %type <a_wsynt> optWithSyntax |
| 401 | %type <a_wsynt> WithSyntax |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 402 | %type <a_wsynt> WithSyntaxList |
| 403 | %type <a_wchunk> WithSyntaxToken |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 404 | %type <a_marker> optMarker Marker |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 405 | %type <a_int> optUNIQUE |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 406 | %type <a_pres> optPresenceConstraint PresenceConstraint |
| 407 | %type <tv_str> ComponentIdList |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 408 | %type <a_int> NSTD_IndirectMarker |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 409 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 410 | %% |
| 411 | |
| 412 | |
| 413 | ParsedGrammar: |
Lev Walkin | 752e973 | 2017-08-04 02:06:22 -0700 | [diff] [blame] | 414 | UTF8_BOM ModuleList { |
| 415 | *(void **)param = $2; |
| 416 | } |
| 417 | | ModuleList { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 418 | *(void **)param = $1; |
| 419 | } |
| 420 | ; |
| 421 | |
| 422 | ModuleList: |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 423 | ModuleDefinition { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 424 | $$ = asn1p_new(); |
| 425 | checkmem($$); |
| 426 | TQ_ADD(&($$->modules), $1, mod_next); |
| 427 | } |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 428 | | ModuleList ModuleDefinition { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 429 | $$ = $1; |
| 430 | TQ_ADD(&($$->modules), $2, mod_next); |
| 431 | } |
| 432 | ; |
| 433 | |
| 434 | /* |
| 435 | * ASN module definition. |
| 436 | * === EXAMPLE === |
| 437 | * MySyntax DEFINITIONS AUTOMATIC TAGS ::= |
| 438 | * BEGIN |
| 439 | * ... |
| 440 | * END |
| 441 | * === EOF === |
| 442 | */ |
| 443 | |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 444 | ModuleDefinition: |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 445 | TypeRefName { currentModule = asn1p_module_new(); } |
| 446 | optObjectIdentifier TOK_DEFINITIONS |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 447 | optModuleDefinitionFlags |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 448 | TOK_PPEQ TOK_BEGIN |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 449 | optModuleBody |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 450 | TOK_END { |
| 451 | |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 452 | $$ = currentModule; |
| 453 | |
| 454 | if($8) { |
| 455 | asn1p_module_t tmp = *($$); |
| 456 | *($$) = *($8); |
| 457 | *($8) = tmp; |
| 458 | asn1p_module_free($8); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 459 | } else { |
| 460 | /* There's a chance that a module is just plain empty */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 461 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 462 | |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 463 | $$->ModuleName = $1; |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 464 | $$->module_oid = $3; |
| 465 | $$->module_flags = $5; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 466 | } |
| 467 | ; |
| 468 | |
| 469 | /* |
| 470 | * Object Identifier Definition |
| 471 | * { iso member-body(2) 3 } |
| 472 | */ |
| 473 | optObjectIdentifier: |
| 474 | { $$ = 0; } |
| 475 | | ObjectIdentifier { $$ = $1; } |
| 476 | ; |
| 477 | |
| 478 | ObjectIdentifier: |
| 479 | '{' ObjectIdentifierBody '}' { |
| 480 | $$ = $2; |
| 481 | } |
| 482 | | '{' '}' { |
| 483 | $$ = 0; |
| 484 | } |
| 485 | ; |
| 486 | |
| 487 | ObjectIdentifierBody: |
| 488 | ObjectIdentifierElement { |
| 489 | $$ = asn1p_oid_new(); |
| 490 | asn1p_oid_add_arc($$, &$1); |
| 491 | if($1.name) |
| 492 | free($1.name); |
| 493 | } |
| 494 | | ObjectIdentifierBody ObjectIdentifierElement { |
| 495 | $$ = $1; |
| 496 | asn1p_oid_add_arc($$, &$2); |
| 497 | if($2.name) |
| 498 | free($2.name); |
| 499 | } |
| 500 | ; |
| 501 | |
| 502 | ObjectIdentifierElement: |
| 503 | Identifier { /* iso */ |
| 504 | $$.name = $1; |
| 505 | $$.number = -1; |
| 506 | } |
| 507 | | Identifier '(' TOK_number ')' { /* iso(1) */ |
| 508 | $$.name = $1; |
| 509 | $$.number = $3; |
| 510 | } |
| 511 | | TOK_number { /* 1 */ |
| 512 | $$.name = 0; |
| 513 | $$.number = $1; |
| 514 | } |
| 515 | ; |
| 516 | |
| 517 | /* |
| 518 | * Optional module flags. |
| 519 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 520 | optModuleDefinitionFlags: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 521 | { $$ = MSF_NOFLAGS; } |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 522 | | ModuleDefinitionFlags { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 523 | $$ = $1; |
| 524 | } |
| 525 | ; |
| 526 | |
| 527 | /* |
| 528 | * Module flags. |
| 529 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 530 | ModuleDefinitionFlags: |
| 531 | ModuleDefinitionFlag { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 532 | $$ = $1; |
| 533 | } |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 534 | | ModuleDefinitionFlags ModuleDefinitionFlag { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 535 | $$ = $1 | $2; |
| 536 | } |
| 537 | ; |
| 538 | |
| 539 | /* |
| 540 | * Single module flag. |
| 541 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 542 | ModuleDefinitionFlag: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 543 | TOK_EXPLICIT TOK_TAGS { |
| 544 | $$ = MSF_EXPLICIT_TAGS; |
| 545 | } |
| 546 | | TOK_IMPLICIT TOK_TAGS { |
| 547 | $$ = MSF_IMPLICIT_TAGS; |
| 548 | } |
| 549 | | TOK_AUTOMATIC TOK_TAGS { |
| 550 | $$ = MSF_AUTOMATIC_TAGS; |
| 551 | } |
| 552 | | TOK_EXTENSIBILITY TOK_IMPLIED { |
| 553 | $$ = MSF_EXTENSIBILITY_IMPLIED; |
| 554 | } |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 555 | /* EncodingReferenceDefault */ |
| 556 | | TOK_capitalreference TOK_INSTRUCTIONS { |
| 557 | /* X.680Amd1 specifies TAG and XER */ |
| 558 | if(strcmp($1, "TAG") == 0) { |
| 559 | $$ = MSF_TAG_INSTRUCTIONS; |
| 560 | } else if(strcmp($1, "XER") == 0) { |
| 561 | $$ = MSF_XER_INSTRUCTIONS; |
| 562 | } else { |
| 563 | fprintf(stderr, |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 564 | "WARNING: %s INSTRUCTIONS at %s:%d: " |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 565 | "Unrecognized encoding reference\n", |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 566 | $1, ASN_FILENAME, yylineno); |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 567 | $$ = MSF_unk_INSTRUCTIONS; |
| 568 | } |
| 569 | free($1); |
| 570 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 571 | ; |
| 572 | |
| 573 | /* |
| 574 | * Optional module body. |
| 575 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 576 | optModuleBody: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 577 | { $$ = 0; } |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 578 | | ModuleBody { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 579 | $$ = $1; |
| 580 | } |
| 581 | ; |
| 582 | |
| 583 | /* |
| 584 | * ASN.1 Module body. |
| 585 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 586 | ModuleBody: |
| 587 | optExports optImports AssignmentList { |
| 588 | $$ = asn1p_module_new(); |
| 589 | AL_IMPORT($$, exports, $1, xp_next); |
| 590 | AL_IMPORT($$, imports, $2, xp_next); |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 591 | asn1p_module_move_members($$, $3); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 592 | |
| 593 | asn1p_module_free($1); |
| 594 | asn1p_module_free($2); |
| 595 | asn1p_module_free($3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 596 | } |
| 597 | ; |
| 598 | |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 599 | AssignmentList: |
| 600 | Assignment { |
| 601 | $$ = $1; |
| 602 | } |
| 603 | | AssignmentList Assignment { |
| 604 | if($1) { |
| 605 | $$ = $1; |
| 606 | } else { |
| 607 | $$ = $2; |
| 608 | break; |
| 609 | } |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 610 | asn1p_module_move_members($$, $2); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 611 | asn1p_module_free($2); |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 612 | } |
| 613 | ; |
| 614 | |
| 615 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 616 | /* |
| 617 | * One of the elements of ASN.1 module specification. |
| 618 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 619 | Assignment: |
| 620 | DataTypeReference { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 621 | $$ = asn1p_module_new(); |
| 622 | checkmem($$); |
| 623 | assert($1->expr_type != A1TC_INVALID); |
| 624 | assert($1->meta_type != AMT_INVALID); |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 625 | asn1p_module_member_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 626 | } |
Lev Walkin | c6ab03c | 2006-10-21 05:54:49 +0000 | [diff] [blame] | 627 | | ValueAssignment { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 628 | $$ = asn1p_module_new(); |
| 629 | checkmem($$); |
| 630 | assert($1->expr_type != A1TC_INVALID); |
| 631 | assert($1->meta_type != AMT_INVALID); |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 632 | asn1p_module_member_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 633 | } |
| 634 | /* |
| 635 | * Value set definition |
| 636 | * === EXAMPLE === |
| 637 | * EvenNumbers INTEGER ::= { 2 | 4 | 6 | 8 } |
| 638 | * === EOF === |
Lev Walkin | e700b20 | 2017-08-06 23:21:32 -0700 | [diff] [blame] | 639 | * Also ObjectClassSet. |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 640 | */ |
Lev Walkin | 557f27d | 2006-03-21 07:46:48 +0000 | [diff] [blame] | 641 | | ValueSetTypeAssignment { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 642 | $$ = asn1p_module_new(); |
| 643 | checkmem($$); |
| 644 | assert($1->expr_type != A1TC_INVALID); |
| 645 | assert($1->meta_type != AMT_INVALID); |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 646 | asn1p_module_member_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 647 | } |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 648 | | TOK_ENCODING_CONTROL TOK_capitalreference |
| 649 | { asn1p_lexer_hack_push_encoding_control(); } |
| 650 | { |
| 651 | fprintf(stderr, |
| 652 | "WARNING: ENCODING-CONTROL %s " |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 653 | "specification at %s:%d ignored\n", |
| 654 | $2, ASN_FILENAME, yylineno); |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 655 | free($2); |
| 656 | $$ = 0; |
| 657 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 658 | |
| 659 | /* |
| 660 | * Erroneous attemps |
| 661 | */ |
| 662 | | BasicString { |
| 663 | return yyerror( |
Lev Walkin | 7085305 | 2005-11-26 11:21:55 +0000 | [diff] [blame] | 664 | "Attempt to redefine a standard basic string type, " |
| 665 | "please comment out or remove this type redefinition."); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 666 | } |
| 667 | ; |
| 668 | |
| 669 | /* |
| 670 | * === EXAMPLE === |
| 671 | * IMPORTS Type1, value FROM Module { iso standard(0) } ; |
| 672 | * === EOF === |
| 673 | */ |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 674 | optImports: |
| 675 | { $$ = 0; } |
| 676 | | ImportsDefinition; |
| 677 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 678 | ImportsDefinition: |
Lev Walkin | 4a4543f | 2006-10-13 12:37:39 +0000 | [diff] [blame] | 679 | TOK_IMPORTS optImportsBundleSet ';' { |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 680 | if(!saved_aid && 0) |
| 681 | return yyerror("Unterminated IMPORTS FROM, " |
| 682 | "expected semicolon ';'"); |
| 683 | saved_aid = 0; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 684 | $$ = $2; |
| 685 | } |
| 686 | /* |
| 687 | * Some error cases. |
| 688 | */ |
| 689 | | TOK_IMPORTS TOK_FROM /* ... */ { |
| 690 | return yyerror("Empty IMPORTS list"); |
| 691 | } |
| 692 | ; |
| 693 | |
Lev Walkin | 4a4543f | 2006-10-13 12:37:39 +0000 | [diff] [blame] | 694 | optImportsBundleSet: |
| 695 | { $$ = asn1p_module_new(); } |
| 696 | | ImportsBundleSet; |
| 697 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 698 | ImportsBundleSet: |
| 699 | ImportsBundle { |
| 700 | $$ = asn1p_module_new(); |
| 701 | checkmem($$); |
| 702 | TQ_ADD(&($$->imports), $1, xp_next); |
| 703 | } |
| 704 | | ImportsBundleSet ImportsBundle { |
| 705 | $$ = $1; |
| 706 | TQ_ADD(&($$->imports), $2, xp_next); |
| 707 | } |
| 708 | ; |
| 709 | |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 710 | AssignedIdentifier: |
| 711 | { memset(&$$, 0, sizeof($$)); } |
| 712 | | ObjectIdentifier { $$.oid = $1; }; |
| 713 | /* | DefinedValue { $$.value = $1; }; // Handled through saved_aid */ |
| 714 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 715 | ImportsBundle: |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 716 | ImportsList TOK_FROM TypeRefName AssignedIdentifier { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 717 | $$ = $1; |
Lev Walkin | 1ed2209 | 2005-08-12 10:06:17 +0000 | [diff] [blame] | 718 | $$->fromModuleName = $3; |
| 719 | $$->identifier = $4; |
| 720 | /* This stupid thing is used for look-back hack. */ |
| 721 | saved_aid = $$->identifier.oid ? 0 : &($$->identifier); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 722 | checkmem($$); |
| 723 | } |
| 724 | ; |
| 725 | |
| 726 | ImportsList: |
| 727 | ImportsElement { |
| 728 | $$ = asn1p_xports_new(); |
| 729 | checkmem($$); |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 730 | TQ_ADD(&($$->xp_members), $1, next); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 731 | } |
| 732 | | ImportsList ',' ImportsElement { |
| 733 | $$ = $1; |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 734 | TQ_ADD(&($$->xp_members), $3, next); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 735 | } |
| 736 | ; |
| 737 | |
| 738 | ImportsElement: |
| 739 | TypeRefName { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 740 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 741 | checkmem($$); |
| 742 | $$->Identifier = $1; |
| 743 | $$->expr_type = A1TC_REFERENCE; |
| 744 | } |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 745 | | TypeRefName '{' '}' { /* Completely equivalent to above */ |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 746 | $$ = NEW_EXPR(); |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 747 | checkmem($$); |
| 748 | $$->Identifier = $1; |
| 749 | $$->expr_type = A1TC_REFERENCE; |
| 750 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 751 | | Identifier { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 752 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 753 | checkmem($$); |
| 754 | $$->Identifier = $1; |
| 755 | $$->expr_type = A1TC_REFERENCE; |
| 756 | } |
| 757 | ; |
| 758 | |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 759 | |
| 760 | optExports: |
| 761 | { $$ = 0; } |
| 762 | | ExportsDefinition { |
| 763 | $$ = asn1p_module_new(); |
| 764 | checkmem($$); |
| 765 | if($1) { |
| 766 | TQ_ADD(&($$->exports), $1, xp_next); |
| 767 | } else { |
| 768 | /* "EXPORTS ALL;" */ |
| 769 | } |
| 770 | } |
| 771 | ; |
| 772 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 773 | ExportsDefinition: |
| 774 | TOK_EXPORTS ExportsBody ';' { |
| 775 | $$ = $2; |
| 776 | } |
| 777 | | TOK_EXPORTS TOK_ALL ';' { |
| 778 | $$ = 0; |
| 779 | } |
| 780 | | TOK_EXPORTS ';' { |
| 781 | /* Empty EXPORTS clause effectively prohibits export. */ |
| 782 | $$ = asn1p_xports_new(); |
| 783 | checkmem($$); |
| 784 | } |
| 785 | ; |
| 786 | |
| 787 | ExportsBody: |
| 788 | ExportsElement { |
| 789 | $$ = asn1p_xports_new(); |
| 790 | assert($$); |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 791 | TQ_ADD(&($$->xp_members), $1, next); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 792 | } |
| 793 | | ExportsBody ',' ExportsElement { |
| 794 | $$ = $1; |
Lev Walkin | 1a49ced | 2017-11-06 00:07:00 -0800 | [diff] [blame] | 795 | TQ_ADD(&($$->xp_members), $3, next); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 796 | } |
| 797 | ; |
| 798 | |
| 799 | ExportsElement: |
| 800 | TypeRefName { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 801 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 802 | checkmem($$); |
| 803 | $$->Identifier = $1; |
| 804 | $$->expr_type = A1TC_EXPORTVAR; |
| 805 | } |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 806 | | TypeRefName '{' '}' { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 807 | $$ = NEW_EXPR(); |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 808 | checkmem($$); |
| 809 | $$->Identifier = $1; |
| 810 | $$->expr_type = A1TC_EXPORTVAR; |
| 811 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 812 | | Identifier { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 813 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 814 | checkmem($$); |
| 815 | $$->Identifier = $1; |
| 816 | $$->expr_type = A1TC_EXPORTVAR; |
| 817 | } |
| 818 | ; |
| 819 | |
| 820 | |
Lev Walkin | 418298d | 2006-07-13 08:24:20 +0000 | [diff] [blame] | 821 | ValueSet: '{' ElementSetSpecs '}' { $$ = $2; }; |
Lev Walkin | 557f27d | 2006-03-21 07:46:48 +0000 | [diff] [blame] | 822 | |
| 823 | ValueSetTypeAssignment: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 824 | TypeRefName Type TOK_PPEQ ValueSet { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 825 | $$ = $2; |
| 826 | assert($$->Identifier == 0); |
| 827 | $$->Identifier = $1; |
| 828 | $$->meta_type = AMT_VALUESET; |
Lev Walkin | 557f27d | 2006-03-21 07:46:48 +0000 | [diff] [blame] | 829 | $$->constraints = $4; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 830 | } |
| 831 | ; |
| 832 | |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 833 | DefinedType: |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 834 | /* |
| 835 | * A DefinedType reference. |
| 836 | * "CLASS1.&id.&id2" |
| 837 | * or |
| 838 | * "Module.Type" |
| 839 | * or |
| 840 | * "Module.identifier" |
| 841 | * or |
| 842 | * "Type" |
| 843 | */ |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 844 | ComplexTypeReference { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 845 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 846 | checkmem($$); |
| 847 | $$->reference = $1; |
| 848 | $$->expr_type = A1TC_REFERENCE; |
| 849 | $$->meta_type = AMT_TYPEREF; |
| 850 | } |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 851 | /* |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 852 | * A parameterized assignment. |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 853 | */ |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 854 | | ComplexTypeReference '{' ActualParameterList '}' { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 855 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 856 | checkmem($$); |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 857 | $$->reference = $1; |
| 858 | $$->rhs_pspecs = $3; |
| 859 | $$->expr_type = A1TC_REFERENCE; |
| 860 | $$->meta_type = AMT_TYPEREF; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 861 | } |
| 862 | ; |
| 863 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 864 | /* |
| 865 | * Data Type Reference. |
| 866 | * === EXAMPLE === |
| 867 | * Type3 ::= CHOICE { a Type1, b Type 2 } |
| 868 | * === EOF === |
| 869 | */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 870 | DataTypeReference: |
| 871 | /* |
| 872 | * Optionally tagged type definition. |
| 873 | */ |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 874 | TypeRefName TOK_PPEQ Type { |
Lev Walkin | af120f7 | 2004-09-14 02:36:39 +0000 | [diff] [blame] | 875 | $$ = $3; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 876 | $$->Identifier = $1; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 877 | assert($$->expr_type); |
| 878 | assert($$->meta_type); |
| 879 | } |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 880 | | TypeRefName TOK_PPEQ ObjectClass { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 881 | $$ = $3; |
| 882 | $$->Identifier = $1; |
| 883 | assert($$->expr_type == A1TC_CLASSDEF); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 884 | assert($$->meta_type == AMT_OBJECTCLASS); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 885 | } |
| 886 | /* |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 887 | * Parameterized <Type> declaration: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 888 | * === EXAMPLE === |
| 889 | * SIGNED { ToBeSigned } ::= SEQUENCE { |
| 890 | * toBeSigned ToBeSigned, |
| 891 | * algorithm AlgorithmIdentifier, |
| 892 | * signature BIT STRING |
| 893 | * } |
| 894 | * === EOF === |
| 895 | */ |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 896 | | TypeRefName '{' ParameterArgumentList '}' TOK_PPEQ Type { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 897 | $$ = $6; |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 898 | $$->Identifier = $1; |
| 899 | $$->lhs_params = $3; |
| 900 | } |
| 901 | /* Parameterized CLASS declaration */ |
| 902 | | TypeRefName '{' ParameterArgumentList '}' TOK_PPEQ ObjectClass { |
| 903 | $$ = $6; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 904 | $$->Identifier = $1; |
Lev Walkin | a00d6b3 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 905 | $$->lhs_params = $3; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 906 | } |
| 907 | ; |
| 908 | |
| 909 | ParameterArgumentList: |
| 910 | ParameterArgumentName { |
| 911 | int ret; |
| 912 | $$ = asn1p_paramlist_new(yylineno); |
| 913 | checkmem($$); |
| 914 | ret = asn1p_paramlist_add_param($$, $1.governor, $1.argument); |
| 915 | checkmem(ret == 0); |
Lev Walkin | a964e03 | 2017-03-26 03:48:06 -0700 | [diff] [blame] | 916 | asn1p_ref_free($1.governor); |
| 917 | free($1.argument); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 918 | } |
| 919 | | ParameterArgumentList ',' ParameterArgumentName { |
| 920 | int ret; |
| 921 | $$ = $1; |
| 922 | ret = asn1p_paramlist_add_param($$, $3.governor, $3.argument); |
| 923 | checkmem(ret == 0); |
Lev Walkin | a964e03 | 2017-03-26 03:48:06 -0700 | [diff] [blame] | 924 | asn1p_ref_free($3.governor); |
| 925 | free($3.argument); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 926 | } |
| 927 | ; |
| 928 | |
| 929 | ParameterArgumentName: |
| 930 | TypeRefName { |
| 931 | $$.governor = NULL; |
| 932 | $$.argument = $1; |
| 933 | } |
| 934 | | TypeRefName ':' Identifier { |
| 935 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 936 | $$.governor = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 937 | ret = asn1p_ref_add_component($$.governor, $1, 0); |
| 938 | checkmem(ret == 0); |
| 939 | $$.argument = $3; |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 940 | free($1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 941 | } |
Lev Walkin | c8092cb | 2005-02-18 16:34:21 +0000 | [diff] [blame] | 942 | | TypeRefName ':' TypeRefName { |
| 943 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 944 | $$.governor = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | c8092cb | 2005-02-18 16:34:21 +0000 | [diff] [blame] | 945 | ret = asn1p_ref_add_component($$.governor, $1, 0); |
| 946 | checkmem(ret == 0); |
| 947 | $$.argument = $3; |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 948 | free($1); |
Lev Walkin | c8092cb | 2005-02-18 16:34:21 +0000 | [diff] [blame] | 949 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 950 | | BasicTypeId ':' Identifier { |
| 951 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 952 | $$.governor = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 953 | ret = asn1p_ref_add_component($$.governor, |
| 954 | ASN_EXPR_TYPE2STR($1), 1); |
| 955 | checkmem(ret == 0); |
| 956 | $$.argument = $3; |
| 957 | } |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 958 | | BasicTypeId ':' TypeRefName { |
| 959 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 960 | $$.governor = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 961 | ret = asn1p_ref_add_component($$.governor, |
| 962 | ASN_EXPR_TYPE2STR($1), 1); |
| 963 | checkmem(ret == 0); |
| 964 | $$.argument = $3; |
| 965 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 966 | ; |
| 967 | |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 968 | ActualParameterList: |
| 969 | ActualParameter { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 970 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 971 | checkmem($$); |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 972 | asn1p_expr_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 973 | } |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 974 | | ActualParameterList ',' ActualParameter { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 975 | $$ = $1; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 976 | asn1p_expr_add($$, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 977 | } |
| 978 | ; |
| 979 | |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 980 | ActualParameter: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 981 | UntaggedType /* act. Type */ |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 982 | | SimpleValue { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 983 | $$ = NEW_EXPR(); |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 984 | checkmem($$); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 985 | $$->Identifier = strdup("?"); |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 986 | $$->expr_type = A1TC_REFERENCE; |
| 987 | $$->meta_type = AMT_VALUE; |
| 988 | $$->value = $1; |
| 989 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 990 | | DefinedValue { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 991 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 992 | checkmem($$); |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 993 | $$->Identifier = strdup("?"); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 994 | $$->expr_type = A1TC_REFERENCE; |
| 995 | $$->meta_type = AMT_VALUE; |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 996 | $$->value = $1; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 997 | } |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 998 | | ValueSet { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 999 | $$ = NEW_EXPR(); |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 1000 | $$->expr_type = A1TC_VALUESET; |
| 1001 | $$->meta_type = AMT_VALUESET; |
| 1002 | $$->constraints = $1; |
| 1003 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1004 | ; |
| 1005 | |
| 1006 | /* |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 1007 | | '{' ActualParameter '}' { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1008 | $$ = NEW_EXPR(); |
Lev Walkin | c8092cb | 2005-02-18 16:34:21 +0000 | [diff] [blame] | 1009 | checkmem($$); |
| 1010 | asn1p_expr_add($$, $2); |
| 1011 | $$->expr_type = A1TC_PARAMETRIZED; |
| 1012 | $$->meta_type = AMT_TYPE; |
| 1013 | } |
| 1014 | ; |
| 1015 | */ |
| 1016 | |
| 1017 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1018 | * A collection of constructed data type members. |
| 1019 | */ |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 1020 | optComponentTypeLists: |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1021 | { $$ = NEW_EXPR(); } |
Lev Walkin | 144db9b | 2004-10-12 23:26:53 +0000 | [diff] [blame] | 1022 | | ComponentTypeLists { $$ = $1; }; |
| 1023 | |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1024 | ComponentTypeLists: |
| 1025 | ComponentType { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1026 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1027 | checkmem($$); |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1028 | asn1p_expr_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1029 | } |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1030 | | ComponentTypeLists ',' ComponentType { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1031 | $$ = $1; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1032 | asn1p_expr_add($$, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1033 | } |
Lev Walkin | 0e90aa0 | 2013-03-19 16:17:13 -0700 | [diff] [blame] | 1034 | | ComponentTypeLists ',' TOK_VBracketLeft ComponentTypeLists TOK_VBracketRight { |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1035 | $$ = $1; |
Lev Walkin | 0e90aa0 | 2013-03-19 16:17:13 -0700 | [diff] [blame] | 1036 | asn1p_expr_add_many($$, $4); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1037 | asn1p_expr_free($4); |
Lev Walkin | 0e90aa0 | 2013-03-19 16:17:13 -0700 | [diff] [blame] | 1038 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1039 | ; |
| 1040 | |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1041 | ComponentType: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1042 | Identifier MaybeIndirectTaggedType optMarker { |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1043 | $$ = $2; |
| 1044 | assert($$->Identifier == 0); |
Lev Walkin | af120f7 | 2004-09-14 02:36:39 +0000 | [diff] [blame] | 1045 | $$->Identifier = $1; |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1046 | $3.flags |= $$->marker.flags; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1047 | $$->marker = $3; |
| 1048 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1049 | | MaybeIndirectTaggedType optMarker { |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1050 | $$ = $1; |
| 1051 | $2.flags |= $$->marker.flags; |
| 1052 | $$->marker = $2; |
| 1053 | _fixup_anonymous_identifier($$); |
| 1054 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1055 | | TOK_COMPONENTS TOK_OF MaybeIndirectTaggedType { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1056 | $$ = NEW_EXPR(); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1057 | checkmem($$); |
| 1058 | $$->meta_type = $3->meta_type; |
| 1059 | $$->expr_type = A1TC_COMPONENTS_OF; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1060 | asn1p_expr_add($$, $3); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1061 | } |
| 1062 | | ExtensionAndException { |
| 1063 | $$ = $1; |
| 1064 | } |
| 1065 | ; |
| 1066 | |
| 1067 | AlternativeTypeLists: |
| 1068 | AlternativeType { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1069 | $$ = NEW_EXPR(); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1070 | checkmem($$); |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1071 | asn1p_expr_add($$, $1); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1072 | } |
| 1073 | | AlternativeTypeLists ',' AlternativeType { |
| 1074 | $$ = $1; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1075 | asn1p_expr_add($$, $3); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1076 | } |
| 1077 | ; |
| 1078 | |
| 1079 | AlternativeType: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1080 | Identifier MaybeIndirectTaggedType { |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1081 | $$ = $2; |
| 1082 | assert($$->Identifier == 0); |
Lev Walkin | af120f7 | 2004-09-14 02:36:39 +0000 | [diff] [blame] | 1083 | $$->Identifier = $1; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1084 | } |
| 1085 | | ExtensionAndException { |
| 1086 | $$ = $1; |
| 1087 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1088 | | MaybeIndirectTaggedType { |
Lev Walkin | 2e9bd5c | 2005-08-13 09:07:11 +0000 | [diff] [blame] | 1089 | $$ = $1; |
| 1090 | _fixup_anonymous_identifier($$); |
| 1091 | } |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1092 | ; |
| 1093 | |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1094 | ObjectClass: |
| 1095 | TOK_CLASS '{' FieldSpec '}' optWithSyntax { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1096 | $$ = $3; |
| 1097 | checkmem($$); |
| 1098 | $$->with_syntax = $5; |
| 1099 | assert($$->expr_type == A1TC_CLASSDEF); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1100 | assert($$->meta_type == AMT_OBJECTCLASS); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1101 | } |
| 1102 | ; |
| 1103 | |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1104 | optUNIQUE: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1105 | { $$ = 0; } |
| 1106 | | TOK_UNIQUE { $$ = 1; } |
| 1107 | ; |
| 1108 | |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1109 | FieldSpec: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1110 | ClassField { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1111 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1112 | checkmem($$); |
| 1113 | $$->expr_type = A1TC_CLASSDEF; |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1114 | $$->meta_type = AMT_OBJECTCLASS; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1115 | asn1p_expr_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1116 | } |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1117 | | FieldSpec ',' ClassField { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1118 | $$ = $1; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 1119 | asn1p_expr_add($$, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1120 | } |
| 1121 | ; |
| 1122 | |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1123 | /* X.681 */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1124 | ClassField: |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1125 | |
| 1126 | /* TypeFieldSpec ::= typefieldreference TypeOptionalitySpec? */ |
| 1127 | TOK_typefieldreference optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1128 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1129 | checkmem($$); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1130 | $$->Identifier = $1; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1131 | $$->meta_type = AMT_OBJECTFIELD; |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1132 | $$->expr_type = A1TC_CLASSFIELD_TFS; /* TypeFieldSpec */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1133 | $$->marker = $2; |
| 1134 | } |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1135 | |
| 1136 | /* FixedTypeValueFieldSpec ::= valuefieldreference Type UNIQUE ? ValueOptionalitySpec ? */ |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1137 | | TOK_valuefieldreference Type optUNIQUE optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1138 | $$ = NEW_EXPR(); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1139 | $$->Identifier = $1; |
| 1140 | $$->meta_type = AMT_OBJECTFIELD; |
| 1141 | $$->expr_type = A1TC_CLASSFIELD_FTVFS; /* FixedTypeValueFieldSpec */ |
Lev Walkin | b7c45ca | 2004-11-24 17:43:29 +0000 | [diff] [blame] | 1142 | $$->unique = $3; |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1143 | $$->marker = $4; |
| 1144 | asn1p_expr_add($$, $2); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1145 | } |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1146 | |
| 1147 | /* VariableTypeValueFieldSpec ::= valuefieldreference FieldName ValueOptionalitySpec ? */ |
| 1148 | | TOK_valuefieldreference FieldName optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1149 | $$ = NEW_EXPR(); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1150 | $$->Identifier = $1; |
| 1151 | $$->meta_type = AMT_OBJECTFIELD; |
| 1152 | $$->expr_type = A1TC_CLASSFIELD_VTVFS; |
| 1153 | $$->reference = $2; |
| 1154 | $$->marker = $3; |
| 1155 | } |
| 1156 | |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1157 | /* ObjectFieldSpec ::= objectfieldreference DefinedObjectClass ObjectOptionalitySpec ? */ |
| 1158 | | TOK_valuefieldreference DefinedObjectClass optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1159 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1160 | checkmem($$); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1161 | $$->Identifier = $1; |
| 1162 | $$->reference = $2; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1163 | $$->meta_type = AMT_OBJECTFIELD; |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1164 | $$->expr_type = A1TC_CLASSFIELD_OFS; |
| 1165 | $$->marker = $3; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1166 | } |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1167 | |
Lev Walkin | 5486875 | 2006-03-09 09:08:49 +0000 | [diff] [blame] | 1168 | /* VariableTypeValueSetFieldSpec ::= valuesetfieldreference FieldName ValueOptionalitySpec ? */ |
| 1169 | | TOK_typefieldreference FieldName optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1170 | $$ = NEW_EXPR(); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1171 | $$->Identifier = $1; |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1172 | $$->meta_type = AMT_OBJECTFIELD; |
Lev Walkin | 5486875 | 2006-03-09 09:08:49 +0000 | [diff] [blame] | 1173 | $$->expr_type = A1TC_CLASSFIELD_VTVSFS; |
| 1174 | $$->reference = $2; |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1175 | $$->marker = $3; |
| 1176 | } |
| 1177 | |
| 1178 | /* FixedTypeValueSetFieldSpec ::= valuesetfieldreference Type ValueSetOptionalitySpec ? */ |
| 1179 | | TOK_typefieldreference Type optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1180 | $$ = NEW_EXPR(); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1181 | checkmem($$); |
| 1182 | $$->Identifier = $1; |
| 1183 | $$->meta_type = AMT_OBJECTFIELD; |
| 1184 | $$->expr_type = A1TC_CLASSFIELD_FTVSFS; |
| 1185 | asn1p_expr_add($$, $2); |
| 1186 | $$->marker = $3; |
| 1187 | } |
| 1188 | |
Lev Walkin | 5486875 | 2006-03-09 09:08:49 +0000 | [diff] [blame] | 1189 | /* ObjectSetFieldSpec ::= objectsetfieldreference DefinedObjectClass ObjectOptionalitySpec ? */ |
| 1190 | | TOK_typefieldreference DefinedObjectClass optMarker { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1191 | $$ = NEW_EXPR(); |
Lev Walkin | 5486875 | 2006-03-09 09:08:49 +0000 | [diff] [blame] | 1192 | checkmem($$); |
| 1193 | $$->Identifier = $1; |
| 1194 | $$->reference = $2; |
| 1195 | $$->meta_type = AMT_OBJECTFIELD; |
| 1196 | $$->expr_type = A1TC_CLASSFIELD_OSFS; |
| 1197 | $$->marker = $3; |
| 1198 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1199 | ; |
| 1200 | |
| 1201 | optWithSyntax: |
| 1202 | { $$ = 0; } |
| 1203 | | WithSyntax { |
| 1204 | $$ = $1; |
| 1205 | } |
| 1206 | ; |
| 1207 | |
| 1208 | WithSyntax: |
| 1209 | TOK_WITH TOK_SYNTAX '{' |
| 1210 | { asn1p_lexer_hack_enable_with_syntax(); } |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1211 | WithSyntaxList |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1212 | '}' { |
| 1213 | $$ = $5; |
| 1214 | } |
| 1215 | ; |
| 1216 | |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1217 | WithSyntaxList: |
| 1218 | WithSyntaxToken { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1219 | $$ = asn1p_wsyntx_new(); |
| 1220 | TQ_ADD(&($$->chunks), $1, next); |
| 1221 | } |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1222 | | WithSyntaxList WithSyntaxToken { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1223 | $$ = $1; |
| 1224 | TQ_ADD(&($$->chunks), $2, next); |
| 1225 | } |
| 1226 | ; |
| 1227 | |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1228 | WithSyntaxToken: |
Lev Walkin | 57074f1 | 2006-03-16 05:11:14 +0000 | [diff] [blame] | 1229 | TOK_whitespace { |
Lev Walkin | c46b7cb | 2006-08-18 02:27:55 +0000 | [diff] [blame] | 1230 | $$ = asn1p_wsyntx_chunk_fromstring($1.buf, 0); |
Lev Walkin | 57074f1 | 2006-03-16 05:11:14 +0000 | [diff] [blame] | 1231 | $$->type = WC_WHITESPACE; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1232 | } |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1233 | | TOK_Literal { |
Lev Walkin | c46b7cb | 2006-08-18 02:27:55 +0000 | [diff] [blame] | 1234 | $$ = asn1p_wsyntx_chunk_fromstring($1, 0); |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1235 | } |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 1236 | | PrimitiveFieldReference { |
Lev Walkin | c46b7cb | 2006-08-18 02:27:55 +0000 | [diff] [blame] | 1237 | $$ = asn1p_wsyntx_chunk_fromstring($1.name, 0); |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 1238 | $$->type = WC_FIELD; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1239 | } |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 1240 | | '[' WithSyntaxList ']' { |
| 1241 | $$ = asn1p_wsyntx_chunk_fromsyntax($2); |
| 1242 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1243 | ; |
| 1244 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1245 | ExtensionAndException: |
| 1246 | TOK_ThreeDots { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1247 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1248 | checkmem($$); |
| 1249 | $$->Identifier = strdup("..."); |
| 1250 | checkmem($$->Identifier); |
| 1251 | $$->expr_type = A1TC_EXTENSIBLE; |
| 1252 | $$->meta_type = AMT_TYPE; |
| 1253 | } |
| 1254 | | TOK_ThreeDots '!' DefinedValue { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1255 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1256 | checkmem($$); |
| 1257 | $$->Identifier = strdup("..."); |
| 1258 | checkmem($$->Identifier); |
| 1259 | $$->value = $3; |
| 1260 | $$->expr_type = A1TC_EXTENSIBLE; |
| 1261 | $$->meta_type = AMT_TYPE; |
| 1262 | } |
| 1263 | | TOK_ThreeDots '!' SignedNumber { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1264 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1265 | checkmem($$); |
| 1266 | $$->Identifier = strdup("..."); |
| 1267 | $$->value = $3; |
| 1268 | checkmem($$->Identifier); |
| 1269 | $$->expr_type = A1TC_EXTENSIBLE; |
| 1270 | $$->meta_type = AMT_TYPE; |
| 1271 | } |
| 1272 | ; |
| 1273 | |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1274 | Type: TaggedType; |
| 1275 | |
| 1276 | TaggedType: |
| 1277 | optTag UntaggedType { |
| 1278 | $$ = $2; |
| 1279 | $$->tag = $1; |
| 1280 | } |
| 1281 | ; |
| 1282 | |
| 1283 | DefinedUntaggedType: |
| 1284 | DefinedType optManyConstraints { |
| 1285 | $$ = $1; |
| 1286 | /* |
| 1287 | * Outer constraint for SEQUENCE OF and SET OF applies |
| 1288 | * to the inner type. |
| 1289 | */ |
| 1290 | if($$->expr_type == ASN_CONSTR_SEQUENCE_OF |
| 1291 | || $$->expr_type == ASN_CONSTR_SET_OF) { |
| 1292 | assert(!TQ_FIRST(&($$->members))->constraints); |
| 1293 | TQ_FIRST(&($$->members))->constraints = $2; |
| 1294 | } else { |
| 1295 | if($$->constraints) { |
| 1296 | assert(!$2); |
| 1297 | /* Check this : optManyConstraints is not used ?! */ |
| 1298 | asn1p_constraint_free($2); |
| 1299 | } else { |
| 1300 | $$->constraints = $2; |
| 1301 | } |
| 1302 | } |
| 1303 | } |
| 1304 | ; |
| 1305 | |
| 1306 | UntaggedType: |
| 1307 | TypeDeclaration optManyConstraints { |
| 1308 | $$ = $1; |
| 1309 | /* |
| 1310 | * Outer constraint for SEQUENCE OF and SET OF applies |
| 1311 | * to the inner type. |
| 1312 | */ |
| 1313 | if($$->expr_type == ASN_CONSTR_SEQUENCE_OF |
| 1314 | || $$->expr_type == ASN_CONSTR_SET_OF) { |
| 1315 | assert(!TQ_FIRST(&($$->members))->constraints); |
| 1316 | TQ_FIRST(&($$->members))->constraints = $2; |
| 1317 | } else { |
| 1318 | if($$->constraints) { |
| 1319 | assert(!$2); |
| 1320 | /* Check this : optManyConstraints is not used ?! */ |
| 1321 | asn1p_constraint_free($2); |
| 1322 | } else { |
| 1323 | $$->constraints = $2; |
| 1324 | } |
| 1325 | } |
| 1326 | } |
| 1327 | ; |
| 1328 | |
| 1329 | MaybeIndirectTaggedType: |
| 1330 | optTag MaybeIndirectTypeDeclaration optManyConstraints { |
Lev Walkin | af120f7 | 2004-09-14 02:36:39 +0000 | [diff] [blame] | 1331 | $$ = $2; |
| 1332 | $$->tag = $1; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1333 | /* |
| 1334 | * Outer constraint for SEQUENCE OF and SET OF applies |
| 1335 | * to the inner type. |
| 1336 | */ |
| 1337 | if($$->expr_type == ASN_CONSTR_SEQUENCE_OF |
| 1338 | || $$->expr_type == ASN_CONSTR_SET_OF) { |
| 1339 | assert(!TQ_FIRST(&($$->members))->constraints); |
Lev Walkin | af120f7 | 2004-09-14 02:36:39 +0000 | [diff] [blame] | 1340 | TQ_FIRST(&($$->members))->constraints = $3; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1341 | } else { |
| 1342 | if($$->constraints) { |
| 1343 | assert(!$2); |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1344 | /* Check this : optManyConstraints is not used ?! */ |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1345 | asn1p_constraint_free($3); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1346 | } else { |
Lev Walkin | af120f7 | 2004-09-14 02:36:39 +0000 | [diff] [blame] | 1347 | $$->constraints = $3; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1348 | } |
| 1349 | } |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1350 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1351 | ; |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1352 | |
| 1353 | NSTD_IndirectMarker: |
| 1354 | { |
| 1355 | $$ = asn1p_as_pointer ? EM_INDIRECT : 0; |
| 1356 | asn1p_as_pointer = 0; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1357 | } |
| 1358 | ; |
| 1359 | |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1360 | MaybeIndirectTypeDeclaration: |
| 1361 | NSTD_IndirectMarker TypeDeclaration { |
| 1362 | $$ = $2; |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1363 | $$->marker.flags |= $1; |
| 1364 | |
| 1365 | if(($$->marker.flags & EM_INDIRECT) |
| 1366 | && ($$->marker.flags & EM_OPTIONAL) != EM_OPTIONAL) { |
| 1367 | fprintf(stderr, |
| 1368 | "INFO: Directive <ASN1C:RepresentAsPointer> " |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1369 | "applied to %s at %s:%d\n", |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1370 | ASN_EXPR_TYPE2STR($$->expr_type) |
| 1371 | ? ASN_EXPR_TYPE2STR($$->expr_type) |
| 1372 | : "member", |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1373 | ASN_FILENAME, $$->_lineno |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1374 | ); |
| 1375 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1376 | } |
| 1377 | ; |
Lev Walkin | 4696c74 | 2005-08-22 12:23:54 +0000 | [diff] [blame] | 1378 | |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1379 | TypeDeclaration: |
| 1380 | ConcreteTypeDeclaration |
| 1381 | | DefinedType; |
| 1382 | |
| 1383 | ConcreteTypeDeclaration: |
| 1384 | BuiltinType |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1385 | | TOK_CHOICE '{' AlternativeTypeLists '}' { |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1386 | $$ = $3; |
| 1387 | assert($$->expr_type == A1TC_INVALID); |
| 1388 | $$->expr_type = ASN_CONSTR_CHOICE; |
| 1389 | $$->meta_type = AMT_TYPE; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1390 | } |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1391 | | TOK_SEQUENCE '{' optComponentTypeLists '}' { |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1392 | $$ = $3; |
| 1393 | assert($$->expr_type == A1TC_INVALID); |
| 1394 | $$->expr_type = ASN_CONSTR_SEQUENCE; |
| 1395 | $$->meta_type = AMT_TYPE; |
| 1396 | } |
Lev Walkin | ef62540 | 2005-09-05 05:17:57 +0000 | [diff] [blame] | 1397 | | TOK_SET '{' optComponentTypeLists '}' { |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1398 | $$ = $3; |
| 1399 | assert($$->expr_type == A1TC_INVALID); |
| 1400 | $$->expr_type = ASN_CONSTR_SET; |
| 1401 | $$->meta_type = AMT_TYPE; |
| 1402 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1403 | | TOK_SEQUENCE optSizeOrConstraint TOK_OF optIdentifier optTag MaybeIndirectTypeDeclaration { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1404 | $$ = NEW_EXPR(); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1405 | checkmem($$); |
| 1406 | $$->constraints = $2; |
| 1407 | $$->expr_type = ASN_CONSTR_SEQUENCE_OF; |
| 1408 | $$->meta_type = AMT_TYPE; |
Lev Walkin | 83cac2f | 2004-09-22 16:03:36 +0000 | [diff] [blame] | 1409 | $6->Identifier = $4; |
| 1410 | $6->tag = $5; |
| 1411 | asn1p_expr_add($$, $6); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1412 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1413 | | TOK_SET optSizeOrConstraint TOK_OF optIdentifier optTag MaybeIndirectTypeDeclaration { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1414 | $$ = NEW_EXPR(); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1415 | checkmem($$); |
| 1416 | $$->constraints = $2; |
| 1417 | $$->expr_type = ASN_CONSTR_SET_OF; |
| 1418 | $$->meta_type = AMT_TYPE; |
Lev Walkin | 83cac2f | 2004-09-22 16:03:36 +0000 | [diff] [blame] | 1419 | $6->Identifier = $4; |
| 1420 | $6->tag = $5; |
| 1421 | asn1p_expr_add($$, $6); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1422 | } |
| 1423 | | TOK_ANY { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1424 | $$ = NEW_EXPR(); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1425 | checkmem($$); |
Lev Walkin | 609ccbb | 2004-09-04 04:49:21 +0000 | [diff] [blame] | 1426 | $$->expr_type = ASN_TYPE_ANY; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1427 | $$->meta_type = AMT_TYPE; |
| 1428 | } |
| 1429 | | TOK_ANY TOK_DEFINED TOK_BY Identifier { |
| 1430 | int ret; |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1431 | $$ = NEW_EXPR(); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1432 | checkmem($$); |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1433 | $$->reference = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1434 | ret = asn1p_ref_add_component($$->reference, |
| 1435 | $4, RLT_lowercase); |
| 1436 | checkmem(ret == 0); |
Lev Walkin | 609ccbb | 2004-09-04 04:49:21 +0000 | [diff] [blame] | 1437 | $$->expr_type = ASN_TYPE_ANY; |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1438 | $$->meta_type = AMT_TYPE; |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1439 | free($4); |
Lev Walkin | 070a52d | 2004-08-22 03:19:54 +0000 | [diff] [blame] | 1440 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1441 | | TOK_INSTANCE TOK_OF ComplexTypeReference { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1442 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1443 | checkmem($$); |
| 1444 | $$->reference = $3; |
| 1445 | $$->expr_type = A1TC_INSTANCE; |
| 1446 | $$->meta_type = AMT_TYPE; |
| 1447 | } |
| 1448 | ; |
| 1449 | |
| 1450 | /* |
| 1451 | * A type name consisting of several components. |
| 1452 | * === EXAMPLE === |
| 1453 | * === EOF === |
| 1454 | */ |
| 1455 | ComplexTypeReference: |
| 1456 | TOK_typereference { |
| 1457 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1458 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1459 | checkmem($$); |
| 1460 | ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); |
| 1461 | checkmem(ret == 0); |
| 1462 | free($1); |
| 1463 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1464 | | TOK_capitalreference { |
| 1465 | int ret; |
| 1466 | $$ = asn1p_ref_new(yylineno, currentModule); |
| 1467 | checkmem($$); |
| 1468 | ret = asn1p_ref_add_component($$, $1, RLT_CAPITALS); |
| 1469 | free($1); |
| 1470 | checkmem(ret == 0); |
| 1471 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1472 | | TOK_typereference '.' TypeRefName { |
| 1473 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1474 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1475 | checkmem($$); |
| 1476 | ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); |
| 1477 | checkmem(ret == 0); |
| 1478 | ret = asn1p_ref_add_component($$, $3, RLT_UNKNOWN); |
| 1479 | checkmem(ret == 0); |
| 1480 | free($1); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1481 | free($3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1482 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1483 | | TOK_capitalreference '.' TypeRefName { |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1484 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1485 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1486 | checkmem($$); |
| 1487 | ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); |
| 1488 | checkmem(ret == 0); |
| 1489 | ret = asn1p_ref_add_component($$, $3, RLT_UNKNOWN); |
| 1490 | checkmem(ret == 0); |
| 1491 | free($1); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1492 | free($3); |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1493 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1494 | | TOK_capitalreference '.' ComplexTypeReferenceAmpList { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1495 | int ret; |
| 1496 | $$ = $3; |
| 1497 | ret = asn1p_ref_add_component($$, $1, RLT_CAPITALS); |
| 1498 | free($1); |
| 1499 | checkmem(ret == 0); |
| 1500 | /* |
| 1501 | * Move the last element infront. |
| 1502 | */ |
| 1503 | { |
| 1504 | struct asn1p_ref_component_s tmp_comp; |
| 1505 | tmp_comp = $$->components[$$->comp_count-1]; |
| 1506 | memmove(&$$->components[1], |
| 1507 | &$$->components[0], |
| 1508 | sizeof($$->components[0]) |
| 1509 | * ($$->comp_count - 1)); |
| 1510 | $$->components[0] = tmp_comp; |
| 1511 | } |
| 1512 | } |
| 1513 | ; |
| 1514 | |
| 1515 | ComplexTypeReferenceAmpList: |
| 1516 | ComplexTypeReferenceElement { |
| 1517 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1518 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1519 | checkmem($$); |
| 1520 | ret = asn1p_ref_add_component($$, $1.name, $1.lex_type); |
| 1521 | free($1.name); |
| 1522 | checkmem(ret == 0); |
| 1523 | } |
| 1524 | | ComplexTypeReferenceAmpList '.' ComplexTypeReferenceElement { |
| 1525 | int ret; |
| 1526 | $$ = $1; |
| 1527 | ret = asn1p_ref_add_component($$, $3.name, $3.lex_type); |
| 1528 | free($3.name); |
| 1529 | checkmem(ret == 0); |
| 1530 | } |
| 1531 | ; |
| 1532 | |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 1533 | ComplexTypeReferenceElement: PrimitiveFieldReference; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1534 | |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 1535 | PrimitiveFieldReference: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1536 | /* "&Type1" */ |
| 1537 | TOK_typefieldreference { |
| 1538 | $$.lex_type = RLT_AmpUppercase; |
| 1539 | $$.name = $1; |
| 1540 | } |
| 1541 | /* "&id" */ |
| 1542 | | TOK_valuefieldreference { |
| 1543 | $$.lex_type = RLT_Amplowercase; |
| 1544 | $$.name = $1; |
| 1545 | } |
| 1546 | ; |
| 1547 | |
| 1548 | |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1549 | FieldName: |
| 1550 | /* "&Type1" */ |
| 1551 | TOK_typefieldreference { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1552 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1553 | asn1p_ref_add_component($$, $1, RLT_AmpUppercase); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1554 | free($1); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1555 | } |
| 1556 | | FieldName '.' TOK_typefieldreference { |
| 1557 | $$ = $$; |
| 1558 | asn1p_ref_add_component($$, $3, RLT_AmpUppercase); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1559 | free($3); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1560 | } |
| 1561 | | FieldName '.' TOK_valuefieldreference { |
| 1562 | $$ = $$; |
| 1563 | asn1p_ref_add_component($$, $3, RLT_Amplowercase); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1564 | free($3); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1565 | } |
| 1566 | ; |
| 1567 | |
| 1568 | DefinedObjectClass: |
| 1569 | TOK_capitalreference { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1570 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1571 | asn1p_ref_add_component($$, $1, RLT_CAPITALS); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1572 | free($1); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1573 | } |
Lev Walkin | 5486875 | 2006-03-09 09:08:49 +0000 | [diff] [blame] | 1574 | /* |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1575 | | TypeRefName '.' TOK_capitalreference { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1576 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1577 | asn1p_ref_add_component($$, $1, RLT_AmpUppercase); |
| 1578 | asn1p_ref_add_component($$, $3, RLT_CAPITALS); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1579 | free($1); |
| 1580 | free($3); |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1581 | } |
Lev Walkin | 5486875 | 2006-03-09 09:08:49 +0000 | [diff] [blame] | 1582 | */ |
Lev Walkin | 9c2285a | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 1583 | ; |
| 1584 | |
| 1585 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1586 | /* |
| 1587 | * === EXAMPLE === |
| 1588 | * value INTEGER ::= 1 |
| 1589 | * === EOF === |
| 1590 | */ |
Lev Walkin | c6ab03c | 2006-10-21 05:54:49 +0000 | [diff] [blame] | 1591 | ValueAssignment: |
| 1592 | Identifier Type TOK_PPEQ Value { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1593 | $$ = $2; |
| 1594 | assert($$->Identifier == NULL); |
| 1595 | $$->Identifier = $1; |
| 1596 | $$->meta_type = AMT_VALUE; |
| 1597 | $$->value = $4; |
| 1598 | } |
| 1599 | ; |
| 1600 | |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1601 | Value: |
Lev Walkin | 0c0bca6 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 1602 | SimpleValue |
| 1603 | | DefinedValue |
Lev Walkin | bf97915 | 2017-09-07 23:36:11 -0700 | [diff] [blame] | 1604 | | '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1605 | $$ = asn1p_value_frombuf($3.buf, $3.len, 0); |
| 1606 | checkmem($$); |
| 1607 | $$->type = ATV_UNPARSED; |
| 1608 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1609 | ; |
| 1610 | |
| 1611 | SimpleValue: |
| 1612 | TOK_NULL { |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1613 | $$ = asn1p_value_fromint(0); |
| 1614 | checkmem($$); |
| 1615 | $$->type = ATV_NULL; |
| 1616 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1617 | | TOK_FALSE { |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1618 | $$ = asn1p_value_fromint(0); |
| 1619 | checkmem($$); |
| 1620 | $$->type = ATV_FALSE; |
| 1621 | } |
| 1622 | | TOK_TRUE { |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1623 | $$ = asn1p_value_fromint(1); |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1624 | checkmem($$); |
| 1625 | $$->type = ATV_TRUE; |
| 1626 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1627 | | SignedNumber |
| 1628 | | RealValue |
| 1629 | | RestrictedCharacterStringValue |
| 1630 | | BitStringValue |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1631 | ; |
| 1632 | |
| 1633 | DefinedValue: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1634 | IdentifierAsValue |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1635 | | TypeRefName '.' Identifier { |
| 1636 | asn1p_ref_t *ref; |
| 1637 | int ret; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1638 | ref = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1639 | checkmem(ref); |
| 1640 | ret = asn1p_ref_add_component(ref, $1, RLT_UNKNOWN); |
| 1641 | checkmem(ret == 0); |
| 1642 | ret = asn1p_ref_add_component(ref, $3, RLT_lowercase); |
| 1643 | checkmem(ret == 0); |
| 1644 | $$ = asn1p_value_fromref(ref, 0); |
| 1645 | checkmem($$); |
| 1646 | free($1); |
| 1647 | free($3); |
| 1648 | } |
| 1649 | ; |
| 1650 | |
Lev Walkin | 1e448d3 | 2005-03-24 14:26:38 +0000 | [diff] [blame] | 1651 | |
| 1652 | RestrictedCharacterStringValue: |
| 1653 | TOK_cstring { |
| 1654 | $$ = asn1p_value_frombuf($1.buf, $1.len, 0); |
| 1655 | checkmem($$); |
| 1656 | } |
Lev Walkin | d9574ae | 2005-03-24 16:22:35 +0000 | [diff] [blame] | 1657 | | TOK_tuple { |
| 1658 | $$ = asn1p_value_fromint($1); |
| 1659 | checkmem($$); |
| 1660 | $$->type = ATV_TUPLE; |
| 1661 | } |
| 1662 | | TOK_quadruple { |
| 1663 | $$ = asn1p_value_fromint($1); |
| 1664 | checkmem($$); |
| 1665 | $$->type = ATV_QUADRUPLE; |
| 1666 | } |
Lev Walkin | 1e448d3 | 2005-03-24 14:26:38 +0000 | [diff] [blame] | 1667 | ; |
| 1668 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1669 | Opaque: |
Lev Walkin | bf97915 | 2017-09-07 23:36:11 -0700 | [diff] [blame] | 1670 | OpaqueFirstToken { |
Lev Walkin | 1893ddf | 2005-03-20 14:28:32 +0000 | [diff] [blame] | 1671 | $$.len = $1.len + 1; |
Lev Walkin | bf97915 | 2017-09-07 23:36:11 -0700 | [diff] [blame] | 1672 | $$.buf = malloc(1 + $$.len + 1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1673 | checkmem($$.buf); |
| 1674 | $$.buf[0] = '{'; |
Lev Walkin | 1893ddf | 2005-03-20 14:28:32 +0000 | [diff] [blame] | 1675 | memcpy($$.buf + 1, $1.buf, $1.len); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1676 | $$.buf[$$.len] = '\0'; |
| 1677 | free($1.buf); |
Lev Walkin | bf97915 | 2017-09-07 23:36:11 -0700 | [diff] [blame] | 1678 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1679 | | Opaque TOK_opaque { |
| 1680 | int newsize = $1.len + $2.len; |
| 1681 | char *p = malloc(newsize + 1); |
| 1682 | checkmem(p); |
| 1683 | memcpy(p , $1.buf, $1.len); |
| 1684 | memcpy(p + $1.len, $2.buf, $2.len); |
| 1685 | p[newsize] = '\0'; |
| 1686 | free($1.buf); |
| 1687 | free($2.buf); |
| 1688 | $$.buf = p; |
| 1689 | $$.len = newsize; |
| 1690 | } |
| 1691 | ; |
| 1692 | |
Lev Walkin | bf97915 | 2017-09-07 23:36:11 -0700 | [diff] [blame] | 1693 | OpaqueFirstToken: |
| 1694 | TOK_opaque |
| 1695 | | Identifier { |
| 1696 | $$.len = strlen($1); |
| 1697 | $$.buf = $1; |
| 1698 | }; |
| 1699 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1700 | BasicTypeId: |
| 1701 | TOK_BOOLEAN { $$ = ASN_BASIC_BOOLEAN; } |
| 1702 | | TOK_NULL { $$ = ASN_BASIC_NULL; } |
| 1703 | | TOK_REAL { $$ = ASN_BASIC_REAL; } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1704 | | TOK_OCTET TOK_STRING { $$ = ASN_BASIC_OCTET_STRING; } |
| 1705 | | TOK_OBJECT TOK_IDENTIFIER { $$ = ASN_BASIC_OBJECT_IDENTIFIER; } |
| 1706 | | TOK_RELATIVE_OID { $$ = ASN_BASIC_RELATIVE_OID; } |
| 1707 | | TOK_EXTERNAL { $$ = ASN_BASIC_EXTERNAL; } |
| 1708 | | TOK_EMBEDDED TOK_PDV { $$ = ASN_BASIC_EMBEDDED_PDV; } |
| 1709 | | TOK_CHARACTER TOK_STRING { $$ = ASN_BASIC_CHARACTER_STRING; } |
| 1710 | | TOK_UTCTime { $$ = ASN_BASIC_UTCTime; } |
| 1711 | | TOK_GeneralizedTime { $$ = ASN_BASIC_GeneralizedTime; } |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 1712 | | BasicString |
| 1713 | | BasicTypeId_UniverationCompatible |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1714 | ; |
| 1715 | |
| 1716 | /* |
| 1717 | * A type identifier which may be used with "{ a(1), b(2) }" clause. |
| 1718 | */ |
| 1719 | BasicTypeId_UniverationCompatible: |
| 1720 | TOK_INTEGER { $$ = ASN_BASIC_INTEGER; } |
Lev Walkin | a25584b | 2017-10-01 13:43:17 -0700 | [diff] [blame] | 1721 | | TOK_ENUMERATED { $$ = ASN_BASIC_ENUMERATED; } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1722 | | TOK_BIT TOK_STRING { $$ = ASN_BASIC_BIT_STRING; } |
| 1723 | ; |
| 1724 | |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1725 | BuiltinType: |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1726 | BasicTypeId { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 1727 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1728 | checkmem($$); |
| 1729 | $$->expr_type = $1; |
| 1730 | $$->meta_type = AMT_TYPE; |
| 1731 | } |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 1732 | | TOK_INTEGER '{' NamedNumberList '}' { |
| 1733 | $$ = $3; |
| 1734 | $$->expr_type = ASN_BASIC_INTEGER; |
| 1735 | $$->meta_type = AMT_TYPE; |
| 1736 | } |
| 1737 | | TOK_ENUMERATED '{' Enumerations '}' { |
| 1738 | $$ = $3; |
| 1739 | $$->expr_type = ASN_BASIC_ENUMERATED; |
| 1740 | $$->meta_type = AMT_TYPE; |
| 1741 | } |
| 1742 | | TOK_BIT TOK_STRING '{' NamedBitList '}' { |
| 1743 | $$ = $4; |
| 1744 | $$->expr_type = ASN_BASIC_BIT_STRING; |
| 1745 | $$->meta_type = AMT_TYPE; |
| 1746 | } |
| 1747 | | TOK_ExtValue_BIT_STRING '{' IdentifierList '}' { |
| 1748 | $$ = $3; |
| 1749 | $$->expr_type = ASN_BASIC_BIT_STRING; |
| 1750 | $$->meta_type = AMT_TYPE; |
| 1751 | } |
| 1752 | | TOK_ExtValue_BIT_STRING '{' '}' { |
| 1753 | $$ = NEW_EXPR(); |
| 1754 | checkmem($$); |
| 1755 | $$->expr_type = ASN_BASIC_BIT_STRING; |
| 1756 | $$->meta_type = AMT_TYPE; |
| 1757 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1758 | ; |
| 1759 | |
| 1760 | BasicString: |
| 1761 | TOK_BMPString { $$ = ASN_STRING_BMPString; } |
| 1762 | | TOK_GeneralString { |
| 1763 | $$ = ASN_STRING_GeneralString; |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1764 | fprintf(stderr, "WARNING: GeneralString is not fully supported\n"); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1765 | } |
| 1766 | | TOK_GraphicString { |
| 1767 | $$ = ASN_STRING_GraphicString; |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1768 | fprintf(stderr, "WARNING: GraphicString is not fully supported\n"); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1769 | } |
| 1770 | | TOK_IA5String { $$ = ASN_STRING_IA5String; } |
| 1771 | | TOK_ISO646String { $$ = ASN_STRING_ISO646String; } |
| 1772 | | TOK_NumericString { $$ = ASN_STRING_NumericString; } |
| 1773 | | TOK_PrintableString { $$ = ASN_STRING_PrintableString; } |
| 1774 | | TOK_T61String { |
| 1775 | $$ = ASN_STRING_T61String; |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1776 | fprintf(stderr, "WARNING: T61String is not fully supported\n"); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1777 | } |
| 1778 | | TOK_TeletexString { $$ = ASN_STRING_TeletexString; } |
| 1779 | | TOK_UniversalString { $$ = ASN_STRING_UniversalString; } |
| 1780 | | TOK_UTF8String { $$ = ASN_STRING_UTF8String; } |
| 1781 | | TOK_VideotexString { |
| 1782 | $$ = ASN_STRING_VideotexString; |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 1783 | fprintf(stderr, "WARNING: VideotexString is not fully supported\n"); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1784 | } |
| 1785 | | TOK_VisibleString { $$ = ASN_STRING_VisibleString; } |
| 1786 | | TOK_ObjectDescriptor { $$ = ASN_STRING_ObjectDescriptor; } |
| 1787 | ; |
| 1788 | |
Lev Walkin | d2ea1de | 2004-08-20 13:25:29 +0000 | [diff] [blame] | 1789 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1790 | /* |
| 1791 | * Data type constraints. |
| 1792 | */ |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 1793 | UnionMark: '|' | TOK_UNION; |
| 1794 | IntersectionMark: '^' | TOK_INTERSECTION; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1795 | |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1796 | /* empty | Constraint */ |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1797 | optConstraint: |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 1798 | { $$ = 0; } |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1799 | | Constraint; |
Lev Walkin | d2ea1de | 2004-08-20 13:25:29 +0000 | [diff] [blame] | 1800 | |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1801 | /* empty | Constraint... */ |
| 1802 | optManyConstraints: |
| 1803 | { $$ = 0; } |
| 1804 | | ManyConstraints; |
| 1805 | |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1806 | /* empty | Constraint | SIZE(...) */ |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1807 | optSizeOrConstraint: |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1808 | { $$ = 0; } |
| 1809 | | Constraint |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1810 | | SizeConstraint |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1811 | ; |
| 1812 | |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1813 | Constraint: |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1814 | '(' ConstraintSpec ')' { |
| 1815 | CONSTRAINT_INSERT($$, ACT_CA_SET, $2, 0); |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1816 | } |
| 1817 | ; |
| 1818 | |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1819 | ManyConstraints: |
| 1820 | Constraint |
| 1821 | | ManyConstraints Constraint { |
| 1822 | if($2->type == ACT_CA_SET && $2->el_count == 1) { |
| 1823 | CONSTRAINT_INSERT($$, ACT_CA_SET, $1, $2->elements[0]); |
| 1824 | } else { |
| 1825 | CONSTRAINT_INSERT($$, ACT_CA_SET, $1, $2); |
| 1826 | } |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 1827 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1828 | ; |
| 1829 | |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1830 | ConstraintSpec: SubtypeConstraint | GeneralConstraint; |
| 1831 | |
| 1832 | SubtypeConstraint: ElementSetSpecs; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1833 | |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 1834 | ElementSetSpecs: |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 1835 | TOK_ThreeDots { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1836 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | 5045dfa | 2006-03-21 09:41:28 +0000 | [diff] [blame] | 1837 | $$->type = ACT_EL_EXT; |
| 1838 | } |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1839 | | ElementSetSpec |
| 1840 | | ElementSetSpec ',' TOK_ThreeDots { |
| 1841 | asn1p_constraint_t *ct; |
| 1842 | ct = asn1p_constraint_new(yylineno, currentModule); |
| 1843 | ct->type = ACT_EL_EXT; |
| 1844 | CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); |
| 1845 | } |
| 1846 | | ElementSetSpec ',' TOK_ThreeDots ',' ElementSetSpec { |
| 1847 | asn1p_constraint_t *ct; |
| 1848 | ct = asn1p_constraint_new(yylineno, currentModule); |
| 1849 | ct->type = ACT_EL_EXT; |
| 1850 | CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); |
| 1851 | ct = $$; |
| 1852 | CONSTRAINT_INSERT($$, ACT_CA_CSV, ct, $5); |
| 1853 | } |
| 1854 | ; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1855 | |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 1856 | ElementSetSpec: |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 1857 | Unions |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1858 | | TOK_ALL TOK_EXCEPT Elements { |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 1859 | CONSTRAINT_INSERT($$, ACT_CA_AEX, $3, 0); |
Lev Walkin | 1e448d3 | 2005-03-24 14:26:38 +0000 | [diff] [blame] | 1860 | } |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 1861 | ; |
| 1862 | |
| 1863 | Unions: |
| 1864 | Intersections |
| 1865 | | Unions UnionMark Intersections { |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 1866 | CONSTRAINT_INSERT($$, ACT_CA_UNI, $1, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1867 | } |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 1868 | ; |
| 1869 | |
| 1870 | Intersections: |
| 1871 | IntersectionElements |
| 1872 | | Intersections IntersectionMark IntersectionElements { |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 1873 | CONSTRAINT_INSERT($$, ACT_CA_INT, $1, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1874 | } |
Lev Walkin | f172715 | 2006-09-21 01:50:37 +0000 | [diff] [blame] | 1875 | ; |
| 1876 | |
| 1877 | |
| 1878 | IntersectionElements: |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1879 | Elements |
| 1880 | | Elements TOK_EXCEPT Elements { |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 1881 | CONSTRAINT_INSERT($$, ACT_CA_EXC, $1, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1882 | } |
| 1883 | ; |
| 1884 | |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1885 | Elements: |
| 1886 | SubtypeElements |
| 1887 | | '(' ElementSetSpec ')' { |
| 1888 | int ret; |
| 1889 | $$ = asn1p_constraint_new(yylineno, currentModule); |
| 1890 | checkmem($$); |
| 1891 | $$->type = ACT_CA_SET; |
| 1892 | ret = asn1p_constraint_insert($$, $2); |
| 1893 | checkmem(ret == 0); |
| 1894 | } |
| 1895 | ; |
| 1896 | |
| 1897 | SubtypeElements: |
| 1898 | SingleValue { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1899 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1900 | checkmem($$); |
| 1901 | $$->type = ACT_EL_VALUE; |
| 1902 | $$->value = $1; |
| 1903 | } |
Lev Walkin | ff7dd14 | 2005-03-20 12:58:00 +0000 | [diff] [blame] | 1904 | | ContainedSubtype { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1905 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | ff7dd14 | 2005-03-20 12:58:00 +0000 | [diff] [blame] | 1906 | checkmem($$); |
| 1907 | $$->type = ACT_EL_TYPE; |
| 1908 | $$->containedSubtype = $1; |
| 1909 | } |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1910 | | PermittedAlphabet /* FROM ... */ |
| 1911 | | SizeConstraint /* SIZE ... */ |
| 1912 | /* | TypeConstraint is via ContainedSubtype */ |
| 1913 | | InnerTypeConstraints /* WITH COMPONENT[S] ... */ |
| 1914 | | PatternConstraint /* PATTERN ... */ |
| 1915 | | ValueRange |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 1916 | ; |
| 1917 | |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1918 | |
| 1919 | PermittedAlphabet: |
| 1920 | TOK_FROM Constraint { |
| 1921 | CONSTRAINT_INSERT($$, ACT_CT_FROM, $2, 0); |
| 1922 | }; |
| 1923 | |
| 1924 | SizeConstraint: |
| 1925 | TOK_SIZE Constraint { |
| 1926 | CONSTRAINT_INSERT($$, ACT_CT_SIZE, $2, 0); |
| 1927 | }; |
| 1928 | |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 1929 | PatternConstraint: |
| 1930 | TOK_PATTERN TOK_cstring { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1931 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 1932 | $$->type = ACT_CT_PATTERN; |
| 1933 | $$->value = asn1p_value_frombuf($2.buf, $2.len, 0); |
| 1934 | } |
| 1935 | | TOK_PATTERN Identifier { |
| 1936 | asn1p_ref_t *ref; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1937 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 1938 | $$->type = ACT_CT_PATTERN; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1939 | ref = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 1940 | asn1p_ref_add_component(ref, $2, RLT_lowercase); |
| 1941 | $$->value = asn1p_value_fromref(ref, 0); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1942 | free($2); |
Lev Walkin | 5c541f1 | 2006-10-18 18:40:14 +0000 | [diff] [blame] | 1943 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1944 | ; |
| 1945 | |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1946 | ValueRange: |
| 1947 | LowerEndValue ConstraintRangeSpec UpperEndValue { |
| 1948 | $$ = asn1p_constraint_new(yylineno, currentModule); |
| 1949 | checkmem($$); |
| 1950 | $$->type = $2; |
| 1951 | $$->range_start = $1; |
| 1952 | $$->range_stop = $3; |
| 1953 | }; |
| 1954 | |
| 1955 | LowerEndValue: |
| 1956 | SingleValue |
| 1957 | | TOK_MIN { |
| 1958 | $$ = asn1p_value_fromint(-123); |
| 1959 | $$->type = ATV_MIN; |
| 1960 | }; |
| 1961 | |
| 1962 | UpperEndValue: |
| 1963 | SingleValue |
| 1964 | | TOK_MAX { |
| 1965 | $$ = asn1p_value_fromint(321); |
| 1966 | $$->type = ATV_MAX; |
| 1967 | }; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1968 | |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1969 | SingleValue: Value; |
Lev Walkin | ff7dd14 | 2005-03-20 12:58:00 +0000 | [diff] [blame] | 1970 | |
Lev Walkin | 1c8d5aa | 2006-10-27 05:37:39 +0000 | [diff] [blame] | 1971 | BitStringValue: |
| 1972 | TOK_bstring { |
| 1973 | $$ = _convert_bitstring2binary($1, 'B'); |
| 1974 | checkmem($$); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1975 | free($1); |
Lev Walkin | 1c8d5aa | 2006-10-27 05:37:39 +0000 | [diff] [blame] | 1976 | } |
| 1977 | | TOK_hstring { |
| 1978 | $$ = _convert_bitstring2binary($1, 'H'); |
| 1979 | checkmem($$); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 1980 | free($1); |
Lev Walkin | 1c8d5aa | 2006-10-27 05:37:39 +0000 | [diff] [blame] | 1981 | } |
| 1982 | ; |
| 1983 | |
Lev Walkin | ff7dd14 | 2005-03-20 12:58:00 +0000 | [diff] [blame] | 1984 | ContainedSubtype: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1985 | TOK_INCLUDES Type { |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1986 | $$ = asn1p_value_fromtype($2); |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 1987 | checkmem($$); |
Lev Walkin | ed409e2 | 2017-09-26 18:07:40 -0700 | [diff] [blame] | 1988 | asn1p_expr_free($2); |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1989 | } |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1990 | /* Can't put Type here because of conflicts. Simplified subset */ |
| 1991 | | DefinedUntaggedType { |
| 1992 | $$ = asn1p_value_fromtype($1); |
| 1993 | checkmem($$); |
Lev Walkin | ed409e2 | 2017-09-26 18:07:40 -0700 | [diff] [blame] | 1994 | asn1p_expr_free($1); |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 1995 | } |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 1996 | ; |
| 1997 | |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 1998 | /* |
| 1999 | * X.680 08/2015 |
| 2000 | * #51.8.5 |
| 2001 | */ |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 2002 | InnerTypeConstraints: |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2003 | TOK_WITH TOK_COMPONENT SingleTypeConstraint { |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 2004 | CONSTRAINT_INSERT($$, ACT_CT_WCOMP, $3, 0); |
Lev Walkin | e596bf0 | 2005-03-28 15:01:27 +0000 | [diff] [blame] | 2005 | } |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2006 | | TOK_WITH TOK_COMPONENTS MultipleTypeConstraints { |
| 2007 | assert($3->type == ACT_CA_CSV); |
| 2008 | $3->type = ACT_CT_WCOMPS; |
| 2009 | $$ = $3; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2010 | } |
| 2011 | ; |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2012 | SingleTypeConstraint: Constraint; |
| 2013 | MultipleTypeConstraints: FullSpecification | PartialSpecification; |
| 2014 | FullSpecification: '{' TypeConstraints '}' { $$ = $2; }; |
| 2015 | PartialSpecification: |
| 2016 | '{' TOK_ThreeDots ',' TypeConstraints '}' { |
| 2017 | assert($4->type == ACT_CA_CSV); |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2018 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2019 | $$->type = ACT_CA_CSV; |
| 2020 | asn1p_constraint_t *ct = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2021 | checkmem($$); |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2022 | ct->type = ACT_EL_EXT; |
| 2023 | asn1p_constraint_insert($$, ct); |
| 2024 | for(unsigned i = 0; i < $4->el_count; i++) { |
| 2025 | asn1p_constraint_insert($$, $4->elements[i]); |
| 2026 | } |
| 2027 | }; |
| 2028 | TypeConstraints: |
| 2029 | NamedConstraint { |
| 2030 | $$ = asn1p_constraint_new(yylineno, currentModule); |
| 2031 | $$->type = ACT_CA_CSV; |
| 2032 | asn1p_constraint_insert($$, $1); |
| 2033 | } |
| 2034 | | TypeConstraints ',' NamedConstraint { |
| 2035 | $$ = $1; |
| 2036 | asn1p_constraint_insert($$, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2037 | } |
| 2038 | ; |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2039 | NamedConstraint: |
Lev Walkin | 0c68645 | 2017-09-07 22:59:36 -0700 | [diff] [blame] | 2040 | IdentifierAsValue optConstraint optPresenceConstraint { |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2041 | $$ = asn1p_constraint_new(yylineno, currentModule); |
| 2042 | checkmem($$); |
| 2043 | $$->type = ACT_EL_VALUE; |
| 2044 | $$->value = $1; |
| 2045 | if($2) asn1p_constraint_insert($$, $2); |
| 2046 | $$->presence = $3; |
| 2047 | } |
| 2048 | ; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2049 | |
| 2050 | /* |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2051 | * presence constraint for NamedConstraint |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2052 | */ |
| 2053 | optPresenceConstraint: |
| 2054 | { $$ = ACPRES_DEFAULT; } |
| 2055 | | PresenceConstraint { $$ = $1; } |
| 2056 | ; |
| 2057 | |
| 2058 | PresenceConstraint: |
| 2059 | TOK_PRESENT { |
| 2060 | $$ = ACPRES_PRESENT; |
| 2061 | } |
| 2062 | | TOK_ABSENT { |
| 2063 | $$ = ACPRES_ABSENT; |
| 2064 | } |
| 2065 | | TOK_OPTIONAL { |
| 2066 | $$ = ACPRES_OPTIONAL; |
| 2067 | } |
| 2068 | ; |
| 2069 | |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2070 | |
| 2071 | /* X.682 */ |
| 2072 | GeneralConstraint: |
| 2073 | UserDefinedConstraint |
| 2074 | | TableConstraint |
| 2075 | | ContentsConstraint |
| 2076 | ; |
| 2077 | |
| 2078 | UserDefinedConstraint: |
| 2079 | TOK_CONSTRAINED TOK_BY '{' |
| 2080 | { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2081 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2082 | checkmem($$); |
| 2083 | $$->type = ACT_CT_CTDBY; |
| 2084 | $$->value = asn1p_value_frombuf($5.buf, $5.len, 0); |
| 2085 | checkmem($$->value); |
| 2086 | $$->value->type = ATV_UNPARSED; |
| 2087 | } |
| 2088 | ; |
| 2089 | |
| 2090 | ContentsConstraint: |
| 2091 | TOK_CONTAINING Type { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2092 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2093 | $$->type = ACT_CT_CTNG; |
| 2094 | $$->value = asn1p_value_fromtype($2); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 2095 | asn1p_expr_free($2); |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2096 | } |
| 2097 | ; |
| 2098 | |
| 2099 | ConstraintRangeSpec: |
| 2100 | TOK_TwoDots { $$ = ACT_EL_RANGE; } |
| 2101 | | TOK_TwoDots '<' { $$ = ACT_EL_RLRANGE; } |
| 2102 | | '<' TOK_TwoDots { $$ = ACT_EL_LLRANGE; } |
| 2103 | | '<' TOK_TwoDots '<' { $$ = ACT_EL_ULRANGE; } |
| 2104 | ; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2105 | TableConstraint: |
| 2106 | SimpleTableConstraint { |
| 2107 | $$ = $1; |
| 2108 | } |
| 2109 | | ComponentRelationConstraint { |
| 2110 | $$ = $1; |
| 2111 | } |
| 2112 | ; |
| 2113 | |
| 2114 | /* |
| 2115 | * "{ExtensionSet}" |
| 2116 | */ |
| 2117 | SimpleTableConstraint: |
| 2118 | '{' TypeRefName '}' { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2119 | asn1p_ref_t *ref = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2120 | asn1p_constraint_t *ct; |
| 2121 | int ret; |
| 2122 | ret = asn1p_ref_add_component(ref, $2, 0); |
| 2123 | checkmem(ret == 0); |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2124 | ct = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2125 | checkmem($$); |
| 2126 | ct->type = ACT_EL_VALUE; |
| 2127 | ct->value = asn1p_value_fromref(ref, 0); |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 2128 | CONSTRAINT_INSERT($$, ACT_CA_CRC, ct, 0); |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 2129 | free($2); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2130 | } |
| 2131 | ; |
| 2132 | |
| 2133 | ComponentRelationConstraint: |
| 2134 | SimpleTableConstraint '{' AtNotationList '}' { |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 2135 | CONSTRAINT_INSERT($$, ACT_CA_CRC, $1, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2136 | } |
| 2137 | ; |
| 2138 | |
| 2139 | AtNotationList: |
| 2140 | AtNotationElement { |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2141 | $$ = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2142 | checkmem($$); |
| 2143 | $$->type = ACT_EL_VALUE; |
| 2144 | $$->value = asn1p_value_fromref($1, 0); |
| 2145 | } |
| 2146 | | AtNotationList ',' AtNotationElement { |
| 2147 | asn1p_constraint_t *ct; |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2148 | ct = asn1p_constraint_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2149 | checkmem(ct); |
| 2150 | ct->type = ACT_EL_VALUE; |
| 2151 | ct->value = asn1p_value_fromref($3, 0); |
Lev Walkin | 2c14a69 | 2005-08-12 10:08:45 +0000 | [diff] [blame] | 2152 | CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2153 | } |
| 2154 | ; |
| 2155 | |
| 2156 | /* |
| 2157 | * @blah |
| 2158 | */ |
| 2159 | AtNotationElement: |
| 2160 | '@' ComponentIdList { |
| 2161 | char *p = malloc(strlen($2) + 2); |
| 2162 | int ret; |
| 2163 | *p = '@'; |
| 2164 | strcpy(p + 1, $2); |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2165 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2166 | ret = asn1p_ref_add_component($$, p, 0); |
| 2167 | checkmem(ret == 0); |
| 2168 | free(p); |
| 2169 | free($2); |
| 2170 | } |
| 2171 | | '@' '.' ComponentIdList { |
| 2172 | char *p = malloc(strlen($3) + 3); |
| 2173 | int ret; |
| 2174 | p[0] = '@'; |
| 2175 | p[1] = '.'; |
| 2176 | strcpy(p + 2, $3); |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 2177 | $$ = asn1p_ref_new(yylineno, currentModule); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2178 | ret = asn1p_ref_add_component($$, p, 0); |
| 2179 | checkmem(ret == 0); |
| 2180 | free(p); |
| 2181 | free($3); |
| 2182 | } |
| 2183 | ; |
| 2184 | |
| 2185 | /* identifier "." ... */ |
| 2186 | ComponentIdList: |
| 2187 | Identifier { |
| 2188 | $$ = $1; |
| 2189 | } |
| 2190 | | ComponentIdList '.' Identifier { |
| 2191 | int l1 = strlen($1); |
| 2192 | int l3 = strlen($3); |
| 2193 | $$ = malloc(l1 + 1 + l3 + 1); |
| 2194 | memcpy($$, $1, l1); |
| 2195 | $$[l1] = '.'; |
| 2196 | memcpy($$ + l1 + 1, $3, l3); |
| 2197 | $$[l1 + 1 + l3] = '\0'; |
Bi-Ruei, Chiu | 3dcf05b | 2017-05-04 21:45:05 +0800 | [diff] [blame] | 2198 | free($1); |
| 2199 | free($3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2200 | } |
| 2201 | ; |
| 2202 | |
| 2203 | |
| 2204 | |
| 2205 | /* |
| 2206 | * MARKERS |
| 2207 | */ |
| 2208 | |
| 2209 | optMarker: |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 2210 | { |
| 2211 | $$.flags = EM_NOMARK; |
| 2212 | $$.default_value = 0; |
| 2213 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2214 | | Marker { $$ = $1; } |
| 2215 | ; |
| 2216 | |
| 2217 | Marker: |
| 2218 | TOK_OPTIONAL { |
Lev Walkin | 7085305 | 2005-11-26 11:21:55 +0000 | [diff] [blame] | 2219 | $$.flags = EM_OPTIONAL | EM_INDIRECT; |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 2220 | $$.default_value = 0; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2221 | } |
Lev Walkin | 9c97418 | 2004-09-15 11:59:51 +0000 | [diff] [blame] | 2222 | | TOK_DEFAULT Value { |
| 2223 | $$.flags = EM_DEFAULT; |
| 2224 | $$.default_value = $2; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2225 | } |
| 2226 | ; |
| 2227 | |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 2228 | IdentifierList: |
| 2229 | IdentifierElement { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2230 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2231 | checkmem($$); |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 2232 | asn1p_expr_add($$, $1); |
| 2233 | } |
| 2234 | | IdentifierList ',' IdentifierElement { |
| 2235 | $$ = $1; |
| 2236 | asn1p_expr_add($$, $3); |
| 2237 | }; |
| 2238 | |
| 2239 | IdentifierElement: |
| 2240 | Identifier { |
| 2241 | $$ = NEW_EXPR(); |
| 2242 | checkmem($$); |
| 2243 | $$->expr_type = A1TC_UNIVERVAL; |
| 2244 | $$->meta_type = AMT_VALUE; |
| 2245 | $$->Identifier = $1; |
| 2246 | } |
| 2247 | |
| 2248 | NamedNumberList: |
| 2249 | NamedNumber { |
| 2250 | $$ = NEW_EXPR(); |
| 2251 | checkmem($$); |
| 2252 | asn1p_expr_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2253 | } |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 2254 | | NamedNumberList ',' NamedNumber { |
| 2255 | $$ = $1; |
| 2256 | asn1p_expr_add($$, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2257 | } |
| 2258 | ; |
| 2259 | |
Lev Walkin | be518fa | 2017-09-07 02:05:28 -0700 | [diff] [blame] | 2260 | NamedNumber: |
| 2261 | Identifier '(' SignedNumber ')' { |
| 2262 | $$ = NEW_EXPR(); |
| 2263 | checkmem($$); |
| 2264 | $$->expr_type = A1TC_UNIVERVAL; |
| 2265 | $$->meta_type = AMT_VALUE; |
| 2266 | $$->Identifier = $1; |
| 2267 | $$->value = $3; |
| 2268 | } |
| 2269 | | Identifier '(' DefinedValue ')' { |
| 2270 | $$ = NEW_EXPR(); |
| 2271 | checkmem($$); |
| 2272 | $$->expr_type = A1TC_UNIVERVAL; |
| 2273 | $$->meta_type = AMT_VALUE; |
| 2274 | $$->Identifier = $1; |
| 2275 | $$->value = $3; |
| 2276 | }; |
| 2277 | |
| 2278 | NamedBitList: |
| 2279 | NamedBit { |
| 2280 | $$ = NEW_EXPR(); |
| 2281 | checkmem($$); |
| 2282 | asn1p_expr_add($$, $1); |
| 2283 | } |
| 2284 | | NamedBitList ',' NamedBit { |
| 2285 | $$ = $1; |
| 2286 | asn1p_expr_add($$, $3); |
| 2287 | } |
| 2288 | ; |
| 2289 | |
| 2290 | NamedBit: |
| 2291 | Identifier '(' TOK_number ')' { |
| 2292 | $$ = NEW_EXPR(); |
| 2293 | checkmem($$); |
| 2294 | $$->expr_type = A1TC_UNIVERVAL; |
| 2295 | $$->meta_type = AMT_VALUE; |
| 2296 | $$->Identifier = $1; |
| 2297 | $$->value = asn1p_value_fromint($3); |
| 2298 | } |
| 2299 | | Identifier '(' DefinedValue ')' { |
| 2300 | $$ = NEW_EXPR(); |
| 2301 | checkmem($$); |
| 2302 | $$->expr_type = A1TC_UNIVERVAL; |
| 2303 | $$->meta_type = AMT_VALUE; |
| 2304 | $$->Identifier = $1; |
| 2305 | $$->value = $3; |
| 2306 | }; |
| 2307 | |
| 2308 | Enumerations: |
| 2309 | UniverationList { |
| 2310 | $$ = $1; |
| 2311 | asn1p_expr_t *first_memb = TQ_FIRST(&($$->members)); |
| 2312 | if(first_memb) { |
| 2313 | if(first_memb->expr_type == A1TC_EXTENSIBLE) { |
| 2314 | return yyerror( |
| 2315 | "The ENUMERATION cannot start with extension (...)."); |
| 2316 | } |
| 2317 | } else { |
| 2318 | return yyerror( |
| 2319 | "The ENUMERATION list cannot be empty."); |
| 2320 | } |
| 2321 | } |
| 2322 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2323 | UniverationList: |
| 2324 | UniverationElement { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2325 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2326 | checkmem($$); |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 2327 | asn1p_expr_add($$, $1); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2328 | } |
| 2329 | | UniverationList ',' UniverationElement { |
| 2330 | $$ = $1; |
Lev Walkin | 1004aa9 | 2004-09-08 00:28:11 +0000 | [diff] [blame] | 2331 | asn1p_expr_add($$, $3); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2332 | } |
| 2333 | ; |
| 2334 | |
| 2335 | UniverationElement: |
| 2336 | Identifier { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2337 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2338 | checkmem($$); |
| 2339 | $$->expr_type = A1TC_UNIVERVAL; |
| 2340 | $$->meta_type = AMT_VALUE; |
| 2341 | $$->Identifier = $1; |
| 2342 | } |
| 2343 | | Identifier '(' SignedNumber ')' { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2344 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2345 | checkmem($$); |
| 2346 | $$->expr_type = A1TC_UNIVERVAL; |
| 2347 | $$->meta_type = AMT_VALUE; |
| 2348 | $$->Identifier = $1; |
| 2349 | $$->value = $3; |
| 2350 | } |
| 2351 | | Identifier '(' DefinedValue ')' { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2352 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2353 | checkmem($$); |
| 2354 | $$->expr_type = A1TC_UNIVERVAL; |
| 2355 | $$->meta_type = AMT_VALUE; |
| 2356 | $$->Identifier = $1; |
| 2357 | $$->value = $3; |
| 2358 | } |
| 2359 | | SignedNumber { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2360 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2361 | checkmem($$); |
| 2362 | $$->expr_type = A1TC_UNIVERVAL; |
| 2363 | $$->meta_type = AMT_VALUE; |
| 2364 | $$->value = $1; |
| 2365 | } |
| 2366 | | TOK_ThreeDots { |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 2367 | $$ = NEW_EXPR(); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2368 | checkmem($$); |
| 2369 | $$->Identifier = strdup("..."); |
| 2370 | checkmem($$->Identifier); |
| 2371 | $$->expr_type = A1TC_EXTENSIBLE; |
| 2372 | $$->meta_type = AMT_VALUE; |
| 2373 | } |
| 2374 | ; |
| 2375 | |
| 2376 | SignedNumber: |
| 2377 | TOK_number { |
| 2378 | $$ = asn1p_value_fromint($1); |
| 2379 | checkmem($$); |
| 2380 | } |
| 2381 | | TOK_number_negative { |
| 2382 | $$ = asn1p_value_fromint($1); |
| 2383 | checkmem($$); |
| 2384 | } |
| 2385 | ; |
| 2386 | |
Lev Walkin | adf863f | 2006-09-05 16:18:34 +0000 | [diff] [blame] | 2387 | RealValue: |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 2388 | TOK_realnumber { |
Lev Walkin | adf863f | 2006-09-05 16:18:34 +0000 | [diff] [blame] | 2389 | $$ = asn1p_value_fromdouble($1); |
| 2390 | checkmem($$); |
| 2391 | } |
| 2392 | ; |
| 2393 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2394 | /* |
| 2395 | * SEQUENCE definition. |
| 2396 | * === EXAMPLE === |
| 2397 | * Struct1 ::= SEQUENCE { |
| 2398 | * memb1 Struct2, |
| 2399 | * memb2 SEQUENCE OF { |
| 2400 | * memb2-1 Struct 3 |
| 2401 | * } |
| 2402 | * } |
| 2403 | * === EOF === |
| 2404 | */ |
| 2405 | |
| 2406 | |
| 2407 | |
| 2408 | /* |
| 2409 | * SET definition. |
| 2410 | * === EXAMPLE === |
| 2411 | * Person ::= SET { |
| 2412 | * name [0] PrintableString (SIZE(1..20)), |
| 2413 | * country [1] PrintableString (SIZE(1..20)) DEFAULT default-country, |
| 2414 | * } |
| 2415 | * === EOF === |
| 2416 | */ |
| 2417 | |
| 2418 | optTag: |
| 2419 | { memset(&$$, 0, sizeof($$)); } |
| 2420 | | Tag { $$ = $1; } |
| 2421 | ; |
| 2422 | |
| 2423 | Tag: |
Lev Walkin | c603f10 | 2005-01-23 09:51:44 +0000 | [diff] [blame] | 2424 | TagTypeValue TagPlicit { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2425 | $$ = $1; |
Lev Walkin | c603f10 | 2005-01-23 09:51:44 +0000 | [diff] [blame] | 2426 | $$.tag_mode = $2.tag_mode; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2427 | } |
Lev Walkin | c603f10 | 2005-01-23 09:51:44 +0000 | [diff] [blame] | 2428 | ; |
| 2429 | |
| 2430 | TagTypeValue: |
| 2431 | '[' TagClass TOK_number ']' { |
| 2432 | $$ = $2; |
| 2433 | $$.tag_value = $3; |
| 2434 | }; |
| 2435 | |
| 2436 | TagClass: |
| 2437 | { $$.tag_class = TC_CONTEXT_SPECIFIC; } |
| 2438 | | TOK_UNIVERSAL { $$.tag_class = TC_UNIVERSAL; } |
| 2439 | | TOK_APPLICATION { $$.tag_class = TC_APPLICATION; } |
| 2440 | | TOK_PRIVATE { $$.tag_class = TC_PRIVATE; } |
| 2441 | ; |
| 2442 | |
| 2443 | TagPlicit: |
| 2444 | { $$.tag_mode = TM_DEFAULT; } |
| 2445 | | TOK_IMPLICIT { $$.tag_mode = TM_IMPLICIT; } |
| 2446 | | TOK_EXPLICIT { $$.tag_mode = TM_EXPLICIT; } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2447 | ; |
| 2448 | |
| 2449 | TypeRefName: |
| 2450 | TOK_typereference { |
| 2451 | checkmem($1); |
| 2452 | $$ = $1; |
| 2453 | } |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 2454 | | TOK_capitalreference { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2455 | checkmem($1); |
| 2456 | $$ = $1; |
| 2457 | } |
| 2458 | ; |
| 2459 | |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 2460 | |
Lev Walkin | 83cac2f | 2004-09-22 16:03:36 +0000 | [diff] [blame] | 2461 | optIdentifier: |
| 2462 | { $$ = 0; } |
| 2463 | | Identifier { |
| 2464 | $$ = $1; |
| 2465 | } |
Lev Walkin | 8f294e0 | 2005-06-06 08:28:58 +0000 | [diff] [blame] | 2466 | ; |
Lev Walkin | 83cac2f | 2004-09-22 16:03:36 +0000 | [diff] [blame] | 2467 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2468 | Identifier: |
| 2469 | TOK_identifier { |
| 2470 | checkmem($1); |
| 2471 | $$ = $1; |
| 2472 | } |
| 2473 | ; |
| 2474 | |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2475 | IdentifierAsReference: |
| 2476 | Identifier { |
| 2477 | $$ = asn1p_ref_new(yylineno, currentModule); |
| 2478 | asn1p_ref_add_component($$, $1, RLT_lowercase); |
Lev Walkin | ed409e2 | 2017-09-26 18:07:40 -0700 | [diff] [blame] | 2479 | free($1); |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2480 | }; |
| 2481 | |
| 2482 | IdentifierAsValue: |
| 2483 | IdentifierAsReference { |
| 2484 | $$ = asn1p_value_fromref($1, 0); |
| 2485 | }; |
| 2486 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2487 | %% |
| 2488 | |
| 2489 | |
| 2490 | /* |
| 2491 | * Convert Xstring ('0101'B or '5'H) to the binary vector. |
| 2492 | */ |
| 2493 | static asn1p_value_t * |
| 2494 | _convert_bitstring2binary(char *str, int base) { |
| 2495 | asn1p_value_t *val; |
| 2496 | int slen; |
| 2497 | int memlen; |
| 2498 | int baselen; |
| 2499 | int bits; |
| 2500 | uint8_t *binary_vector; |
| 2501 | uint8_t *bv_ptr; |
| 2502 | uint8_t cur_val; |
| 2503 | |
| 2504 | assert(str); |
| 2505 | assert(str[0] == '\''); |
| 2506 | |
| 2507 | switch(base) { |
| 2508 | case 'B': |
| 2509 | baselen = 1; |
| 2510 | break; |
| 2511 | case 'H': |
| 2512 | baselen = 4; |
| 2513 | break; |
| 2514 | default: |
| 2515 | assert(base == 'B' || base == 'H'); |
| 2516 | errno = EINVAL; |
| 2517 | return NULL; |
| 2518 | } |
| 2519 | |
| 2520 | slen = strlen(str); |
| 2521 | assert(str[slen - 1] == base); |
| 2522 | assert(str[slen - 2] == '\''); |
| 2523 | |
| 2524 | memlen = slen / (8 / baselen); /* Conservative estimate */ |
| 2525 | |
| 2526 | bv_ptr = binary_vector = malloc(memlen + 1); |
| 2527 | if(bv_ptr == NULL) |
| 2528 | /* ENOMEM */ |
| 2529 | return NULL; |
| 2530 | |
| 2531 | cur_val = 0; |
| 2532 | bits = 0; |
| 2533 | while(*(++str) != '\'') { |
| 2534 | switch(baselen) { |
| 2535 | case 1: |
| 2536 | switch(*str) { |
| 2537 | case '1': |
| 2538 | cur_val |= 1 << (7 - (bits % 8)); |
| 2539 | case '0': |
| 2540 | break; |
| 2541 | default: |
| 2542 | assert(!"_y UNREACH1"); |
| 2543 | case ' ': case '\r': case '\n': |
| 2544 | continue; |
| 2545 | } |
| 2546 | break; |
| 2547 | case 4: |
| 2548 | switch(*str) { |
| 2549 | case '0': case '1': case '2': case '3': case '4': |
| 2550 | case '5': case '6': case '7': case '8': case '9': |
| 2551 | cur_val |= (*str - '0') << (4 - (bits % 8)); |
| 2552 | break; |
| 2553 | case 'A': case 'B': case 'C': |
| 2554 | case 'D': case 'E': case 'F': |
| 2555 | cur_val |= ((*str - 'A') + 10) |
| 2556 | << (4 - (bits % 8)); |
| 2557 | break; |
| 2558 | default: |
| 2559 | assert(!"_y UNREACH2"); |
| 2560 | case ' ': case '\r': case '\n': |
| 2561 | continue; |
| 2562 | } |
| 2563 | break; |
| 2564 | } |
| 2565 | |
| 2566 | bits += baselen; |
| 2567 | if((bits % 8) == 0) { |
| 2568 | *bv_ptr++ = cur_val; |
| 2569 | cur_val = 0; |
| 2570 | } |
| 2571 | } |
| 2572 | |
| 2573 | *bv_ptr = cur_val; |
| 2574 | assert((bv_ptr - binary_vector) <= memlen); |
| 2575 | |
| 2576 | val = asn1p_value_frombits(binary_vector, bits, 0); |
| 2577 | if(val == NULL) { |
| 2578 | free(binary_vector); |
| 2579 | } |
| 2580 | |
| 2581 | return val; |
| 2582 | } |
| 2583 | |
Lev Walkin | 2e9bd5c | 2005-08-13 09:07:11 +0000 | [diff] [blame] | 2584 | /* |
| 2585 | * For unnamed types (used in old X.208 compliant modules) |
| 2586 | * generate some sort of interim names, to not to force human being to fix |
| 2587 | * the specification's compliance to modern ASN.1 standards. |
| 2588 | */ |
| 2589 | static void |
| 2590 | _fixup_anonymous_identifier(asn1p_expr_t *expr) { |
| 2591 | char *p; |
| 2592 | assert(expr->Identifier == 0); |
| 2593 | |
| 2594 | /* |
| 2595 | * Try to figure out the type name |
| 2596 | * without going too much into details |
| 2597 | */ |
| 2598 | expr->Identifier = ASN_EXPR_TYPE2STR(expr->expr_type); |
| 2599 | if(expr->reference && expr->reference->comp_count > 0) |
| 2600 | expr->Identifier = expr->reference->components[0].name; |
| 2601 | |
| 2602 | fprintf(stderr, |
| 2603 | "WARNING: Line %d: expected lower-case member identifier, " |
| 2604 | "found an unnamed %s.\n" |
| 2605 | "WARNING: Obsolete X.208 syntax detected, " |
| 2606 | "please give the member a name.\n", |
| 2607 | yylineno, expr->Identifier ? expr->Identifier : "type"); |
| 2608 | |
| 2609 | if(!expr->Identifier) |
| 2610 | expr->Identifier = "unnamed"; |
| 2611 | expr->Identifier = strdup(expr->Identifier); |
| 2612 | assert(expr->Identifier); |
| 2613 | /* Make a lowercase identifier from the type name */ |
| 2614 | for(p = expr->Identifier; *p; p++) { |
| 2615 | switch(*p) { |
| 2616 | case 'A' ... 'Z': *p += 32; break; |
| 2617 | case ' ': *p = '_'; break; |
| 2618 | case '-': *p = '_'; break; |
| 2619 | } |
| 2620 | } |
| 2621 | fprintf(stderr, "NOTE: Assigning temporary identifier \"%s\". " |
| 2622 | "Name clash may occur later.\n", |
| 2623 | expr->Identifier); |
| 2624 | } |
| 2625 | |
Lev Walkin | 59165cf | 2017-09-11 06:24:45 -0700 | [diff] [blame] | 2626 | static int |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2627 | yyerror(const char *msg) { |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 2628 | extern char *asn1p_text; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2629 | fprintf(stderr, |
| 2630 | "ASN.1 grammar parse error " |
Lev Walkin | d523ea4 | 2017-09-06 22:15:08 -0700 | [diff] [blame] | 2631 | "near %s:%d (token \"%s\"): %s\n", |
| 2632 | ASN_FILENAME, yylineno, asn1p_text, msg); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 2633 | return -1; |
| 2634 | } |
| 2635 | |