Commit ff7dd147 authored by Lev Walkin's avatar Lev Walkin

ContainedSubtype support

parent 7ec9b4c7
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Added extra const qualifiers into the support code. * Added extra const qualifiers into the support code.
* More RFC variations supported in crfc2asn1.pl. * More RFC variations supported in crfc2asn1.pl.
* Refined string values compatibility. (Test cases 77, 78). * Refined string values compatibility. (Test cases 77, 78).
* Support for ContainedSubtype constraints. (Test case 16).
0.9.12: 2005-Mar-10 0.9.12: 2005-Mar-10
......
...@@ -16,6 +16,3 @@ which is already completed. Also see #3.2. ...@@ -16,6 +16,3 @@ which is already completed. Also see #3.2.
3. MINOR: 3. MINOR:
3.1 Parsing of CONSTRAINED BY clauses 3.1 Parsing of CONSTRAINED BY clauses
3.2 Support for ContainedSubtype constraint.
...@@ -22,6 +22,8 @@ void ...@@ -22,6 +22,8 @@ void
asn1p_constraint_free(asn1p_constraint_t *ct) { asn1p_constraint_free(asn1p_constraint_t *ct) {
if(ct) { if(ct) {
if(ct->containedSubtype)
asn1p_value_free(ct->containedSubtype);
if(ct->value) if(ct->value)
asn1p_value_free(ct->value); asn1p_value_free(ct->value);
if(ct->range_start) if(ct->range_start)
...@@ -59,6 +61,7 @@ asn1p_constraint_clone(asn1p_constraint_t *src) { ...@@ -59,6 +61,7 @@ asn1p_constraint_clone(asn1p_constraint_t *src) {
clone->type = src->type; clone->type = src->type;
clone->presence = src->presence; clone->presence = src->presence;
CLONE(containedSubtype, asn1p_value_clone);
CLONE(value, asn1p_value_clone); CLONE(value, asn1p_value_clone);
CLONE(range_start, asn1p_value_clone); CLONE(range_start, asn1p_value_clone);
CLONE(range_stop, asn1p_value_clone); CLONE(range_stop, asn1p_value_clone);
...@@ -115,6 +118,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) { ...@@ -115,6 +118,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
switch(type) { switch(type) {
case ACT_INVALID: case ACT_INVALID:
return "INVALID"; return "INVALID";
case ACT_EL_TYPE:
return "ContainedSubtype";
case ACT_EL_VALUE: case ACT_EL_VALUE:
return "SingleValue"; return "SingleValue";
case ACT_EL_RANGE: case ACT_EL_RANGE:
......
...@@ -11,7 +11,8 @@ typedef struct asn1p_constraint_s { ...@@ -11,7 +11,8 @@ typedef struct asn1p_constraint_s {
/* /*
* Constraint elements. * Constraint elements.
*/ */
ACT_EL_VALUE, /* 123, "A", T (elementary value) */ ACT_EL_TYPE, /* T (contained subtype) */
ACT_EL_VALUE, /* 123, "A", (elementary value) */
ACT_EL_RANGE, /* 1..2 (elementary range) */ ACT_EL_RANGE, /* 1..2 (elementary range) */
ACT_EL_LLRANGE, /* 1<..2 (elementary range) */ ACT_EL_LLRANGE, /* 1<..2 (elementary range) */
ACT_EL_RLRANGE, /* 1..<2 (elementary range) */ ACT_EL_RLRANGE, /* 1..<2 (elementary range) */
...@@ -43,8 +44,9 @@ typedef struct asn1p_constraint_s { ...@@ -43,8 +44,9 @@ typedef struct asn1p_constraint_s {
} presence; } presence;
/* /*
* A single values. * Separate types and values.
*/ */
asn1p_value_t *containedSubtype;
asn1p_value_t *value; asn1p_value_t *value;
asn1p_value_t *range_start; asn1p_value_t *range_start;
asn1p_value_t *range_stop; asn1p_value_t *range_stop;
......
This diff is collapsed.
...@@ -282,7 +282,8 @@ static asn1p_value_t * ...@@ -282,7 +282,8 @@ static asn1p_value_t *
%type <a_constr> ComponentRelationConstraint %type <a_constr> ComponentRelationConstraint
%type <a_constr> AtNotationList %type <a_constr> AtNotationList
%type <a_ref> AtNotationElement %type <a_ref> AtNotationElement
%type <a_value> ConstraintValue %type <a_value> SingleValue
%type <a_value> ContainedSubtype
%type <a_ctype> ConstraintSpec %type <a_ctype> ConstraintSpec
%type <a_ctype> ConstraintRangeSpec %type <a_ctype> ConstraintRangeSpec
%type <a_wsynt> optWithSyntax %type <a_wsynt> optWithSyntax
...@@ -1572,20 +1573,26 @@ ConstraintSubtypeElement: ...@@ -1572,20 +1573,26 @@ ConstraintSubtypeElement:
ret = asn1p_constraint_insert($$, $2); ret = asn1p_constraint_insert($$, $2);
checkmem(ret == 0); checkmem(ret == 0);
} }
| ConstraintValue { | SingleValue {
$$ = asn1p_constraint_new(yylineno); $$ = asn1p_constraint_new(yylineno);
checkmem($$); checkmem($$);
$$->type = ACT_EL_VALUE; $$->type = ACT_EL_VALUE;
$$->value = $1; $$->value = $1;
} }
| ConstraintValue ConstraintRangeSpec ConstraintValue { | ContainedSubtype {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = ACT_EL_TYPE;
$$->containedSubtype = $1;
}
| SingleValue ConstraintRangeSpec SingleValue {
$$ = asn1p_constraint_new(yylineno); $$ = asn1p_constraint_new(yylineno);
checkmem($$); checkmem($$);
$$->type = $2; $$->type = $2;
$$->range_start = $1; $$->range_start = $1;
$$->range_stop = $3; $$->range_stop = $3;
} }
| TOK_MIN ConstraintRangeSpec ConstraintValue { | TOK_MIN ConstraintRangeSpec SingleValue {
$$ = asn1p_constraint_new(yylineno); $$ = asn1p_constraint_new(yylineno);
checkmem($$); checkmem($$);
$$->type = $2; $$->type = $2;
...@@ -1593,7 +1600,7 @@ ConstraintSubtypeElement: ...@@ -1593,7 +1600,7 @@ ConstraintSubtypeElement:
$$->range_stop = $3; $$->range_stop = $3;
$$->range_start->type = ATV_MIN; $$->range_start->type = ATV_MIN;
} }
| ConstraintValue ConstraintRangeSpec TOK_MAX { | SingleValue ConstraintRangeSpec TOK_MAX {
$$ = asn1p_constraint_new(yylineno); $$ = asn1p_constraint_new(yylineno);
checkmem($$); checkmem($$);
$$->type = $2; $$->type = $2;
...@@ -1634,7 +1641,7 @@ ConstraintSpec: ...@@ -1634,7 +1641,7 @@ ConstraintSpec:
} }
; ;
ConstraintValue: SingleValue:
TOK_FALSE { TOK_FALSE {
$$ = asn1p_value_fromint(0); $$ = asn1p_value_fromint(0);
checkmem($$); checkmem($$);
...@@ -1663,7 +1670,10 @@ ConstraintValue: ...@@ -1663,7 +1670,10 @@ ConstraintValue:
checkmem($$); checkmem($$);
free($1); free($1);
} }
| TypeRefName { ;
ContainedSubtype:
TypeRefName {
asn1p_ref_t *ref; asn1p_ref_t *ref;
int ret; int ret;
ref = asn1p_ref_new(yylineno); ref = asn1p_ref_new(yylineno);
......
...@@ -284,6 +284,9 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -284,6 +284,9 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) {
printf("("); printf("(");
switch(ct->type) { switch(ct->type) {
case ACT_EL_TYPE:
asn1print_value(ct->value, flags);
break;
case ACT_EL_VALUE: case ACT_EL_VALUE:
asn1print_value(ct->value, flags); asn1print_value(ct->value, flags);
break; break;
......
...@@ -12,11 +12,15 @@ ModuleTestConstraint ...@@ -12,11 +12,15 @@ ModuleTestConstraint
BEGIN BEGIN
-- external reference -- external reference
Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z"|"#")) Type0 ::= IA5String (Type6)
Type1 ::= IA5String (SIZE(1..ten,...))(FROM("a".."z"|"#",...))
Type2 ::= IA5String (SIZE (MIN..4)|FROM ("abc")) Type2 ::= IA5String (SIZE (MIN..4)|FROM ("abc"))
Type3 ::= BMPString (SIZE(1)) Type3 ::= BMPString (SIZE(1))
Type4 ::= INTEGER (1..MAX) Type4 ::= INTEGER (1..MAX)
Type5 ::= BOOLEAN (TRUE|FALSE) Type5 ::= BOOLEAN (TRUE|FALSE)
Type6 ::= IA5String (Type1)
ten INTEGER ::= 10
v1 Type1 ::= "#value wi v1 Type1 ::= "#value wi
th ""double quotes""" th ""double quotes"""
......
...@@ -3,7 +3,9 @@ ModuleTestConstraint { iso org(3) dod(6) internet(1) private(4) enterprise(1) ...@@ -3,7 +3,9 @@ ModuleTestConstraint { iso org(3) dod(6) internet(1) private(4) enterprise(1)
DEFINITIONS ::= DEFINITIONS ::=
BEGIN BEGIN
Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z" | "#")) Type0 ::= IA5String (((SIZE(1..10))(FROM("a".."z" | "#"))))
Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z" | "#",...))
Type2 ::= IA5String (SIZE(MIN..4) | FROM("abc")) Type2 ::= IA5String (SIZE(MIN..4) | FROM("abc"))
...@@ -13,6 +15,10 @@ Type4 ::= INTEGER (1..MAX) ...@@ -13,6 +15,10 @@ Type4 ::= INTEGER (1..MAX)
Type5 ::= BOOLEAN (TRUE | FALSE) Type5 ::= BOOLEAN (TRUE | FALSE)
Type6 ::= IA5String ((SIZE(1..10))(FROM("a".."z" | "#")))
ten INTEGER ::= 10
v1 Type1 ::= "#value with ""double quotes""" v1 Type1 ::= "#value with ""double quotes"""
END END
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment