mirror of https://gerrit.osmocom.org/asn1c
new style constraints implementation support
This commit is contained in:
parent
b2664669be
commit
f59d075dad
|
@ -546,9 +546,9 @@ distclean-generic:
|
|||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-rm -f asn1p_y.h
|
||||
-rm -f asn1p_y.c
|
||||
-rm -f asn1p_l.c
|
||||
-rm -f asn1p_y.c
|
||||
-rm -f asn1p_y.h
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
|
||||
|
|
|
@ -108,3 +108,42 @@ asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
|
||||
switch(type) {
|
||||
case ACT_INVALID:
|
||||
return "INVALID";
|
||||
case ACT_EL_VALUE:
|
||||
return "SingleValue";
|
||||
case ACT_EL_RANGE:
|
||||
case ACT_EL_LLRANGE:
|
||||
case ACT_EL_RLRANGE:
|
||||
case ACT_EL_ULRANGE:
|
||||
return "ValueRange";
|
||||
case ACT_EL_EXT:
|
||||
return "...";
|
||||
case ACT_CT_SIZE:
|
||||
return "SizeConstraint";
|
||||
case ACT_CT_FROM:
|
||||
return "PermittedAlphabet";
|
||||
case ACT_CT_WCOMP:
|
||||
return "SingleTypeConstraint";
|
||||
case ACT_CT_WCOMPS:
|
||||
return "MultipleTypeConstraints";
|
||||
case ACT_CA_SET:
|
||||
return "SET";
|
||||
case ACT_CA_CRC:
|
||||
return "ComponentRelationConstraint";
|
||||
case ACT_CA_CSV:
|
||||
return "CSV";
|
||||
case ACT_CA_UNI:
|
||||
return "UNION";
|
||||
case ACT_CA_INT:
|
||||
return "INTERSECTION";
|
||||
case ACT_CA_EXC:
|
||||
return "EXCEPT";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ typedef struct asn1p_constraint_s {
|
|||
int _lineno; /* Position in a source file */
|
||||
} asn1p_constraint_t;
|
||||
|
||||
/* Human-readable constraint type description */
|
||||
char *asn1p_constraint_type2str(enum asn1p_constraint_type_e);
|
||||
|
||||
/*
|
||||
* Constructors and a recursive destructor.
|
||||
|
|
|
@ -57,6 +57,7 @@ asn1p_expr_clone(asn1p_expr_t *expr) {
|
|||
CLCLONE(Identifier, strdup);
|
||||
CLCLONE(reference, asn1p_ref_clone);
|
||||
CLCLONE(constraints, asn1p_constraint_clone);
|
||||
CLCLONE(combined_constraints, asn1p_constraint_clone);
|
||||
CLCLONE(params, asn1p_paramlist_clone);
|
||||
CLCLONE(value, asn1p_value_clone);
|
||||
CLCLONE(with_syntax, asn1p_wsyntx_clone);
|
||||
|
@ -90,6 +91,8 @@ asn1p_expr_free(asn1p_expr_t *expr) {
|
|||
asn1p_ref_free(expr->reference);
|
||||
if(expr->constraints)
|
||||
asn1p_constraint_free(expr->constraints);
|
||||
if(expr->combined_constraints)
|
||||
asn1p_constraint_free(expr->combined_constraints);
|
||||
if(expr->params)
|
||||
asn1p_paramlist_free(expr->params);
|
||||
if(expr->value)
|
||||
|
|
|
@ -124,6 +124,12 @@ typedef struct asn1p_expr_s {
|
|||
*/
|
||||
asn1p_constraint_t *constraints;
|
||||
|
||||
/*
|
||||
* This field is holding the transformed constraints, with all the
|
||||
* parent constraints taken into account.
|
||||
*/
|
||||
asn1p_constraint_t *combined_constraints;
|
||||
|
||||
/*
|
||||
* A list of parameters for parametrized type declaration
|
||||
* (AMT_PARAMTYPE).
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,7 @@
|
|||
int asn1p_lex(void);
|
||||
void asn1p_lexer_hack_push_opaque_state(void); /* Used in .y */
|
||||
void asn1p_lexer_hack_enable_with_syntax(void); /* Used in .y */
|
||||
void asn1p_lexer_hack_push_encoding_control(void); /* Used in .y */
|
||||
|
||||
#define YY_FATAL_ERROR(msg) do { \
|
||||
fprintf(stderr, \
|
||||
|
@ -76,7 +77,7 @@ static asn1_integer_t asn1p_atoi(char *ptr); /* errno is either 0 or ERANGE */
|
|||
%}
|
||||
|
||||
%option never-interactive
|
||||
%option noinput nounput
|
||||
%option noinput
|
||||
%option noyywrap stack
|
||||
/* Performance penalty is OK */
|
||||
%option yylineno
|
||||
|
@ -89,6 +90,7 @@ static asn1_integer_t asn1p_atoi(char *ptr); /* errno is either 0 or ERANGE */
|
|||
%x cpp_comment
|
||||
%x quoted
|
||||
%x opaque
|
||||
%x encoding_control
|
||||
%x with_syntax
|
||||
|
||||
/* Newline */
|
||||
|
@ -190,6 +192,19 @@ WSP [\t\r\v\f\n ]
|
|||
|
||||
}
|
||||
|
||||
<encoding_control>{
|
||||
ENCODING-CONTROL {
|
||||
const char *s = "ENCODING-CONTROL";
|
||||
const char *p = s + sizeof("ENCODING-CONTROL") - 2;
|
||||
for(; p >= s; p--) unput(*p);
|
||||
yy_pop_state();
|
||||
}
|
||||
END unput('D'); unput('N'); unput('E'); yy_pop_state();
|
||||
[^{} \t\r\v\f\n]+
|
||||
[[:alnum:]]+
|
||||
. /* Eat everything else */
|
||||
"\n"
|
||||
}
|
||||
|
||||
'[0-9A-F \t\r\v\f\n]+'H {
|
||||
/* " \t\r\n" weren't allowed in ASN.1:1990. */
|
||||
|
@ -311,6 +326,7 @@ DEFINED {
|
|||
DEFINITIONS return TOK_DEFINITIONS;
|
||||
EMBEDDED return TOK_EMBEDDED;
|
||||
ENCODED return TOK_ENCODED;
|
||||
ENCODING-CONTROL return TOK_ENCODING_CONTROL;
|
||||
END return TOK_END;
|
||||
ENUMERATED return TOK_ENUMERATED;
|
||||
EXCEPT return TOK_EXCEPT;
|
||||
|
@ -330,6 +346,7 @@ IMPLIED return TOK_IMPLIED;
|
|||
IMPORTS return TOK_IMPORTS;
|
||||
INCLUDES return TOK_INCLUDES;
|
||||
INSTANCE return TOK_INSTANCE;
|
||||
INSTRUCTIONS return TOK_INSTRUCTIONS;
|
||||
INTEGER return TOK_INTEGER;
|
||||
INTERSECTION return TOK_INTERSECTION;
|
||||
ISO646String return TOK_ISO646String;
|
||||
|
@ -405,7 +422,7 @@ WITH return TOK_WITH;
|
|||
[A-Z][A-Z0-9-]* {
|
||||
CHECK_DASHES;
|
||||
asn1p_lval.tv_str = strdup(yytext);
|
||||
return TOK_objectclassreference;
|
||||
return TOK_capitalreference;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -460,6 +477,7 @@ WITH return TOK_WITH;
|
|||
|
||||
}
|
||||
|
||||
[|^] return yytext[0]; /* Union, Intersection */
|
||||
|
||||
<*>. {
|
||||
fprintf(stderr,
|
||||
|
@ -485,17 +503,16 @@ WITH return TOK_WITH;
|
|||
/*
|
||||
* Very dirty but wonderful hack allowing to rule states from within .y file.
|
||||
*/
|
||||
void
|
||||
asn1p_lexer_hack_push_opaque_state() {
|
||||
yy_push_state(opaque);
|
||||
}
|
||||
void asn1p_lexer_hack_push_opaque_state() { yy_push_state(opaque); }
|
||||
|
||||
/*
|
||||
* Another hack which disables recognizing some tokens when inside WITH SYNTAX.
|
||||
*/
|
||||
void
|
||||
asn1p_lexer_hack_enable_with_syntax() {
|
||||
yy_push_state(with_syntax);
|
||||
void asn1p_lexer_hack_enable_with_syntax() { yy_push_state(with_syntax); }
|
||||
|
||||
/* Yet another */
|
||||
void asn1p_lexer_hack_push_encoding_control() {
|
||||
yy_push_state(encoding_control);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -9,11 +9,16 @@
|
|||
*/
|
||||
typedef enum asn1p_module_flags {
|
||||
MSF_NOFLAGS,
|
||||
MSF_EXPLICIT_TAGS = 0x1,
|
||||
MSF_IMPLICIT_TAGS = 0x2,
|
||||
MSF_AUTOMATIC_TAGS = 0x4,
|
||||
MSF_EXTENSIBILITY_IMPLIED = 0x8,
|
||||
MSF_unk_INSTRUCTIONS = 0x001,
|
||||
MSF_TAG_INSTRUCTIONS = 0x002,
|
||||
MSF_XER_INSTRUCTIONS = 0x004,
|
||||
MSF_EXPLICIT_TAGS = 0x010,
|
||||
MSF_IMPLICIT_TAGS = 0x020,
|
||||
MSF_AUTOMATIC_TAGS = 0x040,
|
||||
MSF_EXTENSIBILITY_IMPLIED = 0x100,
|
||||
} asn1p_module_flags_e;
|
||||
#define MSF_MASK_INSTRUCTIONS 0x0f
|
||||
#define MSF_MASK_TAGS 0xf0
|
||||
|
||||
/*
|
||||
* === EXAMPLE ===
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -39,7 +39,7 @@ typedef union {
|
|||
#define TOK_number 263
|
||||
#define TOK_number_negative 264
|
||||
#define TOK_typereference 265
|
||||
#define TOK_objectclassreference 266
|
||||
#define TOK_capitalreference 266
|
||||
#define TOK_typefieldreference 267
|
||||
#define TOK_valuefieldreference 268
|
||||
#define TOK_ABSENT 269
|
||||
|
@ -65,68 +65,70 @@ typedef union {
|
|||
#define TOK_DEFINED 289
|
||||
#define TOK_EMBEDDED 290
|
||||
#define TOK_ENCODED 291
|
||||
#define TOK_END 292
|
||||
#define TOK_ENUMERATED 293
|
||||
#define TOK_EXPLICIT 294
|
||||
#define TOK_EXPORTS 295
|
||||
#define TOK_EXTENSIBILITY 296
|
||||
#define TOK_EXTERNAL 297
|
||||
#define TOK_FALSE 298
|
||||
#define TOK_FROM 299
|
||||
#define TOK_GeneralizedTime 300
|
||||
#define TOK_GeneralString 301
|
||||
#define TOK_GraphicString 302
|
||||
#define TOK_IA5String 303
|
||||
#define TOK_IDENTIFIER 304
|
||||
#define TOK_IMPLICIT 305
|
||||
#define TOK_IMPLIED 306
|
||||
#define TOK_IMPORTS 307
|
||||
#define TOK_INCLUDES 308
|
||||
#define TOK_INSTANCE 309
|
||||
#define TOK_INTEGER 310
|
||||
#define TOK_ISO646String 311
|
||||
#define TOK_MAX 312
|
||||
#define TOK_MIN 313
|
||||
#define TOK_MINUS_INFINITY 314
|
||||
#define TOK_NULL 315
|
||||
#define TOK_NumericString 316
|
||||
#define TOK_OBJECT 317
|
||||
#define TOK_ObjectDescriptor 318
|
||||
#define TOK_OCTET 319
|
||||
#define TOK_OF 320
|
||||
#define TOK_OPTIONAL 321
|
||||
#define TOK_PATTERN 322
|
||||
#define TOK_PDV 323
|
||||
#define TOK_PLUS_INFINITY 324
|
||||
#define TOK_PRESENT 325
|
||||
#define TOK_PrintableString 326
|
||||
#define TOK_PRIVATE 327
|
||||
#define TOK_REAL 328
|
||||
#define TOK_RELATIVE_OID 329
|
||||
#define TOK_SEQUENCE 330
|
||||
#define TOK_SET 331
|
||||
#define TOK_SIZE 332
|
||||
#define TOK_STRING 333
|
||||
#define TOK_SYNTAX 334
|
||||
#define TOK_T61String 335
|
||||
#define TOK_TAGS 336
|
||||
#define TOK_TeletexString 337
|
||||
#define TOK_TRUE 338
|
||||
#define TOK_TYPE_IDENTIFIER 339
|
||||
#define TOK_UNIQUE 340
|
||||
#define TOK_UNIVERSAL 341
|
||||
#define TOK_UniversalString 342
|
||||
#define TOK_UTCTime 343
|
||||
#define TOK_UTF8String 344
|
||||
#define TOK_VideotexString 345
|
||||
#define TOK_VisibleString 346
|
||||
#define TOK_WITH 347
|
||||
#define TOK_UNION 348
|
||||
#define TOK_INTERSECTION 349
|
||||
#define TOK_ENCODING_CONTROL 292
|
||||
#define TOK_END 293
|
||||
#define TOK_ENUMERATED 294
|
||||
#define TOK_EXPLICIT 295
|
||||
#define TOK_EXPORTS 296
|
||||
#define TOK_EXTENSIBILITY 297
|
||||
#define TOK_EXTERNAL 298
|
||||
#define TOK_FALSE 299
|
||||
#define TOK_FROM 300
|
||||
#define TOK_GeneralizedTime 301
|
||||
#define TOK_GeneralString 302
|
||||
#define TOK_GraphicString 303
|
||||
#define TOK_IA5String 304
|
||||
#define TOK_IDENTIFIER 305
|
||||
#define TOK_IMPLICIT 306
|
||||
#define TOK_IMPLIED 307
|
||||
#define TOK_IMPORTS 308
|
||||
#define TOK_INCLUDES 309
|
||||
#define TOK_INSTANCE 310
|
||||
#define TOK_INSTRUCTIONS 311
|
||||
#define TOK_INTEGER 312
|
||||
#define TOK_ISO646String 313
|
||||
#define TOK_MAX 314
|
||||
#define TOK_MIN 315
|
||||
#define TOK_MINUS_INFINITY 316
|
||||
#define TOK_NULL 317
|
||||
#define TOK_NumericString 318
|
||||
#define TOK_OBJECT 319
|
||||
#define TOK_ObjectDescriptor 320
|
||||
#define TOK_OCTET 321
|
||||
#define TOK_OF 322
|
||||
#define TOK_OPTIONAL 323
|
||||
#define TOK_PATTERN 324
|
||||
#define TOK_PDV 325
|
||||
#define TOK_PLUS_INFINITY 326
|
||||
#define TOK_PRESENT 327
|
||||
#define TOK_PrintableString 328
|
||||
#define TOK_PRIVATE 329
|
||||
#define TOK_REAL 330
|
||||
#define TOK_RELATIVE_OID 331
|
||||
#define TOK_SEQUENCE 332
|
||||
#define TOK_SET 333
|
||||
#define TOK_SIZE 334
|
||||
#define TOK_STRING 335
|
||||
#define TOK_SYNTAX 336
|
||||
#define TOK_T61String 337
|
||||
#define TOK_TAGS 338
|
||||
#define TOK_TeletexString 339
|
||||
#define TOK_TRUE 340
|
||||
#define TOK_TYPE_IDENTIFIER 341
|
||||
#define TOK_UNIQUE 342
|
||||
#define TOK_UNIVERSAL 343
|
||||
#define TOK_UniversalString 344
|
||||
#define TOK_UTCTime 345
|
||||
#define TOK_UTF8String 346
|
||||
#define TOK_VideotexString 347
|
||||
#define TOK_VisibleString 348
|
||||
#define TOK_WITH 349
|
||||
#define TOK_EXCEPT 350
|
||||
#define TOK_TwoDots 351
|
||||
#define TOK_ThreeDots 352
|
||||
#define TOK_tag 353
|
||||
#define TOK_INTERSECTION 351
|
||||
#define TOK_UNION 352
|
||||
#define TOK_TwoDots 353
|
||||
#define TOK_ThreeDots 354
|
||||
#define TOK_tag 355
|
||||
|
||||
|
||||
extern YYSTYPE asn1p_lval;
|
||||
|
|
|
@ -15,6 +15,7 @@ int yylex(void);
|
|||
int yyerror(const char *msg);
|
||||
void asn1p_lexer_hack_push_opaque_state(void);
|
||||
void asn1p_lexer_hack_enable_with_syntax(void);
|
||||
void asn1p_lexer_hack_push_encoding_control(void);
|
||||
#define yylineno asn1p_lineno
|
||||
extern int asn1p_lineno;
|
||||
|
||||
|
@ -99,7 +100,7 @@ static asn1p_value_t *
|
|||
%token <a_int> TOK_number
|
||||
%token <a_int> TOK_number_negative
|
||||
%token <tv_str> TOK_typereference
|
||||
%token <tv_str> TOK_objectclassreference /* "CLASS1" */
|
||||
%token <tv_str> TOK_capitalreference /* "CLASS1" */
|
||||
%token <tv_str> TOK_typefieldreference /* "&Pork" */
|
||||
%token <tv_str> TOK_valuefieldreference /* "&id" */
|
||||
|
||||
|
@ -129,6 +130,7 @@ static asn1p_value_t *
|
|||
%token TOK_DEFINED
|
||||
%token TOK_EMBEDDED
|
||||
%token TOK_ENCODED
|
||||
%token TOK_ENCODING_CONTROL
|
||||
%token TOK_END
|
||||
%token TOK_ENUMERATED
|
||||
%token TOK_EXPLICIT
|
||||
|
@ -147,6 +149,7 @@ static asn1p_value_t *
|
|||
%token TOK_IMPORTS
|
||||
%token TOK_INCLUDES
|
||||
%token TOK_INSTANCE
|
||||
%token TOK_INSTRUCTIONS
|
||||
%token TOK_INTEGER
|
||||
%token TOK_ISO646String
|
||||
%token TOK_MAX
|
||||
|
@ -186,9 +189,9 @@ static asn1p_value_t *
|
|||
%token TOK_VisibleString
|
||||
%token TOK_WITH
|
||||
|
||||
%left '|' TOK_UNION
|
||||
%left '^' TOK_INTERSECTION
|
||||
%left TOK_EXCEPT
|
||||
%left '^' TOK_INTERSECTION
|
||||
%left '|' TOK_UNION
|
||||
|
||||
/* Misc tags */
|
||||
%token TOK_TwoDots /* .. */
|
||||
|
@ -262,14 +265,10 @@ static asn1p_value_t *
|
|||
%type <a_tag> Tag /* [UNIVERSAL 0] IMPLICIT */
|
||||
%type <a_tag> optTag /* [UNIVERSAL 0] IMPLICIT */
|
||||
%type <a_constr> optConstraints
|
||||
%type <a_constr> Constraints
|
||||
%type <a_constr> SingleConstraint /* (SIZE(2)) */
|
||||
%type <a_constr> ConstraintElementSet /* 1..2,...,3 */
|
||||
%type <a_constr> SetOfConstraints
|
||||
%type <a_constr> ElementSetSpecs /* 1..2,...,3 */
|
||||
%type <a_constr> ElementSetSpec /* 1..2,...,3 */
|
||||
%type <a_constr> ConstraintSubtypeElement /* 1..2 */
|
||||
%type <a_constr> ConstraintElementIntersection
|
||||
%type <a_constr> ConstraintElementException
|
||||
%type <a_constr> ConstraintElementUnion
|
||||
%type <a_constr> ConstraintElement
|
||||
%type <a_constr> SimpleTableConstraint
|
||||
%type <a_constr> TableConstraint
|
||||
%type <a_constr> WithComponents
|
||||
|
@ -429,6 +428,22 @@ ModuleSpecificationFlag:
|
|||
| TOK_EXTENSIBILITY TOK_IMPLIED {
|
||||
$$ = MSF_EXTENSIBILITY_IMPLIED;
|
||||
}
|
||||
/* EncodingReferenceDefault */
|
||||
| TOK_capitalreference TOK_INSTRUCTIONS {
|
||||
/* X.680Amd1 specifies TAG and XER */
|
||||
if(strcmp($1, "TAG") == 0) {
|
||||
$$ = MSF_TAG_INSTRUCTIONS;
|
||||
} else if(strcmp($1, "XER") == 0) {
|
||||
$$ = MSF_XER_INSTRUCTIONS;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"WARNING: %s INSTRUCTIONS at line %d: "
|
||||
"Unrecognized encoding reference\n",
|
||||
$1, yylineno);
|
||||
$$ = MSF_unk_INSTRUCTIONS;
|
||||
}
|
||||
free($1);
|
||||
}
|
||||
;
|
||||
|
||||
/*
|
||||
|
@ -437,7 +452,6 @@ ModuleSpecificationFlag:
|
|||
optModuleSpecificationBody:
|
||||
{ $$ = 0; }
|
||||
| ModuleSpecificationBody {
|
||||
assert($1);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
@ -452,6 +466,12 @@ ModuleSpecificationBody:
|
|||
| ModuleSpecificationBody ModuleSpecificationElement {
|
||||
$$ = $1;
|
||||
|
||||
/* Behave well when one of them is skipped. */
|
||||
if(!($1)) {
|
||||
if($2) $$ = $2;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef MY_IMPORT
|
||||
#error MY_IMPORT DEFINED ELSEWHERE!
|
||||
#endif
|
||||
|
@ -515,6 +535,16 @@ ModuleSpecificationElement:
|
|||
assert($1->meta_type != AMT_INVALID);
|
||||
TQ_ADD(&($$->members), $1, next);
|
||||
}
|
||||
| TOK_ENCODING_CONTROL TOK_capitalreference
|
||||
{ asn1p_lexer_hack_push_encoding_control(); }
|
||||
{
|
||||
fprintf(stderr,
|
||||
"WARNING: ENCODING-CONTROL %s "
|
||||
"specification at line %d ignored\n",
|
||||
$2, yylineno);
|
||||
free($2);
|
||||
$$ = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Erroneous attemps
|
||||
|
@ -662,7 +692,7 @@ DefinedTypeRef:
|
|||
|
||||
optValueSetBody:
|
||||
{ }
|
||||
| ConstraintElementSet {
|
||||
| ElementSetSpecs {
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1346,20 +1376,19 @@ ConstructedType:
|
|||
/*
|
||||
* Data type constraints.
|
||||
*/
|
||||
optConstraints:
|
||||
{ $$ = 0; }
|
||||
| Constraints { $$ = $1; }
|
||||
;
|
||||
|
||||
Union: '|' | TOK_UNION;
|
||||
Intersection: '^' | TOK_INTERSECTION;
|
||||
Except: TOK_EXCEPT;
|
||||
|
||||
Constraints:
|
||||
TOK_SIZE '(' ConstraintElementSet ')' {
|
||||
optConstraints:
|
||||
{ $$ = 0; }
|
||||
| SetOfConstraints {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_SET, $1, 0);
|
||||
}
|
||||
| TOK_SIZE '(' ElementSetSpecs ')' {
|
||||
/*
|
||||
* This is a special case, for compatibility purposes.
|
||||
* It goes without parenthesis.
|
||||
* It goes without parentheses.
|
||||
*/
|
||||
int ret;
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
|
@ -1368,80 +1397,70 @@ Constraints:
|
|||
ret = asn1p_constraint_insert($$, $3);
|
||||
checkmem(ret == 0);
|
||||
}
|
||||
| SingleConstraint {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_SET, $1, 0);
|
||||
}
|
||||
| Constraints SingleConstraint {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_SET, $1, $2);
|
||||
}
|
||||
;
|
||||
|
||||
SingleConstraint:
|
||||
'(' ConstraintElementSet ')' {
|
||||
SetOfConstraints:
|
||||
'(' ElementSetSpecs ')' {
|
||||
$$ = $2;
|
||||
}
|
||||
| SetOfConstraints '(' ElementSetSpecs ')' {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_SET, $1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
ConstraintElementSet:
|
||||
ConstraintElement {
|
||||
ElementSetSpecs:
|
||||
ElementSetSpec {
|
||||
$$ = $1;
|
||||
}
|
||||
| ConstraintElement ',' TOK_ThreeDots {
|
||||
| ElementSetSpec ',' TOK_ThreeDots {
|
||||
asn1p_constraint_t *ct;
|
||||
ct = asn1p_constraint_new(yylineno);
|
||||
checkmem(ct);
|
||||
ct->type = ACT_EL_EXT;
|
||||
CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct);
|
||||
}
|
||||
| ConstraintElement ',' TOK_ThreeDots ',' ConstraintElement {
|
||||
| ElementSetSpec ',' TOK_ThreeDots ',' ElementSetSpec {
|
||||
asn1p_constraint_t *ct;
|
||||
ct = asn1p_constraint_new(yylineno);
|
||||
checkmem(ct);
|
||||
ct->type = ACT_EL_EXT;
|
||||
CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct);
|
||||
ct = $$;
|
||||
CONSTRAINT_INSERT($$, ACT_CA_CSV, ct, $5);
|
||||
}
|
||||
| TOK_ThreeDots {
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = ACT_EL_EXT;
|
||||
}
|
||||
| TOK_ThreeDots ',' ConstraintElement {
|
||||
asn1p_constraint_t *ct;
|
||||
ct = asn1p_constraint_new(yylineno);
|
||||
checkmem(ct);
|
||||
ct->type = ACT_EL_EXT;
|
||||
CONSTRAINT_INSERT($$, ACT_CA_CSV, ct, $3);
|
||||
}
|
||||
;
|
||||
|
||||
ConstraintElement: ConstraintElementUnion { $$ = $1; } ;
|
||||
|
||||
ConstraintElementUnion:
|
||||
ConstraintElementIntersection { $$ = $1; }
|
||||
| ConstraintElementUnion Union ConstraintElementIntersection {
|
||||
ElementSetSpec:
|
||||
ConstraintSubtypeElement {
|
||||
$$ = $1;
|
||||
}
|
||||
| ElementSetSpec Union ConstraintSubtypeElement {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_UNI, $1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
ConstraintElementIntersection:
|
||||
ConstraintElementException { $$ = $1; }
|
||||
| ConstraintElementIntersection Intersection
|
||||
ConstraintElementException {
|
||||
| ElementSetSpec Intersection ConstraintSubtypeElement {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_INT, $1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
ConstraintElementException:
|
||||
ConstraintSubtypeElement { $$ = $1; }
|
||||
| ConstraintElementException Except ConstraintSubtypeElement {
|
||||
| ConstraintSubtypeElement Except ConstraintSubtypeElement {
|
||||
CONSTRAINT_INSERT($$, ACT_CA_EXC, $1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
ConstraintSubtypeElement:
|
||||
ConstraintValue {
|
||||
ConstraintSpec '(' ElementSetSpecs ')' {
|
||||
int ret;
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = $1;
|
||||
ret = asn1p_constraint_insert($$, $3);
|
||||
checkmem(ret == 0);
|
||||
}
|
||||
| '(' ElementSetSpecs ')' {
|
||||
int ret;
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = ACT_CA_SET;
|
||||
ret = asn1p_constraint_insert($$, $2);
|
||||
checkmem(ret == 0);
|
||||
}
|
||||
| ConstraintValue {
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = ACT_EL_VALUE;
|
||||
|
@ -1454,13 +1473,30 @@ ConstraintSubtypeElement:
|
|||
$$->range_start = $1;
|
||||
$$->range_stop = $3;
|
||||
}
|
||||
| ConstraintSpec '(' ConstraintElementSet ')' {
|
||||
int ret;
|
||||
| TOK_MIN ConstraintRangeSpec ConstraintValue {
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = $1;
|
||||
ret = asn1p_constraint_insert($$, $3);
|
||||
checkmem(ret == 0);
|
||||
$$->type = $2;
|
||||
$$->range_start = asn1p_value_fromint(-123);
|
||||
$$->range_stop = $3;
|
||||
$$->range_start->type = ATV_MIN;
|
||||
}
|
||||
| ConstraintValue ConstraintRangeSpec TOK_MAX {
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = $2;
|
||||
$$->range_start = $1;
|
||||
$$->range_stop = asn1p_value_fromint(321);
|
||||
$$->range_stop->type = ATV_MAX;
|
||||
}
|
||||
| TOK_MIN ConstraintRangeSpec TOK_MAX {
|
||||
$$ = asn1p_constraint_new(yylineno);
|
||||
checkmem($$);
|
||||
$$->type = $2;
|
||||
$$->range_start = asn1p_value_fromint(-123);
|
||||
$$->range_stop = asn1p_value_fromint(321);
|
||||
$$->range_start->type = ATV_MIN;
|
||||
$$->range_stop->type = ATV_MAX;
|
||||
}
|
||||
| TableConstraint {
|
||||
$$ = $1;
|
||||
|
@ -1505,16 +1541,7 @@ ConstraintValue:
|
|||
$$ = asn1p_value_frombuf($1.buf, $1.len, 0);
|
||||
checkmem($$);
|
||||
}
|
||||
| TOK_MIN {
|
||||
$$ = asn1p_value_fromint(123);
|
||||
checkmem($$);
|
||||
$$->type = ATV_MIN;
|
||||
}
|
||||
| TOK_MAX {
|
||||
$$ = asn1p_value_fromint(321);
|
||||
checkmem($$);
|
||||
$$->type = ATV_MAX;
|
||||
}
|
||||
|
||||
| TOK_FALSE {
|
||||
$$ = asn1p_value_fromint(0);
|
||||
checkmem($$);
|
||||
|
@ -1841,14 +1868,15 @@ TypeRefName:
|
|||
checkmem($1);
|
||||
$$ = $1;
|
||||
}
|
||||
| TOK_objectclassreference {
|
||||
| TOK_capitalreference {
|
||||
checkmem($1);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
ObjectClassReference:
|
||||
TOK_objectclassreference {
|
||||
TOK_capitalreference {
|
||||
checkmem($1);
|
||||
$$ = $1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue