Commit ff7dd147 authored by Lev Walkin's avatar Lev Walkin

ContainedSubtype support

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