Commit 1893ddfb authored by Lev Walkin's avatar Lev Walkin

parsing support for CONSTRAINED BY

parent 6ffb0141
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* 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). * Support for ContainedSubtype constraints. (Test case 16).
* Parsing support for CONSTRAINED BY. (Test case 79).
0.9.12: 2005-Mar-10 0.9.12: 2005-Mar-10
......
...@@ -10,9 +10,9 @@ which is already completed. Also see #3.2. ...@@ -10,9 +10,9 @@ which is already completed. Also see #3.2.
2. MEDIUM: 2. MEDIUM:
2.1 Support for DEFAULT encoding and decoding, at least in INTEGER/ENUMERATED types. 2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
2.2 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types. Requires something from 1.2 (Information Object Classes).
3. MINOR: 3. MINOR:
3.1 Parsing of CONSTRAINED BY clauses 3.1 Support for DEFAULT encoding and decoding, at least in INTEGER/ENUMERATED types.
...@@ -77,6 +77,8 @@ asn1constraint_compatible(asn1p_expr_type_e expr_type, ...@@ -77,6 +77,8 @@ asn1constraint_compatible(asn1p_expr_type_e expr_type,
default: break; default: break;
} }
return 0; return 0;
case ACT_CT_CTDBY:
return 1;
case ACT_CA_SET: case ACT_CA_SET:
case ACT_CA_CRC: case ACT_CA_CRC:
case ACT_CA_CSV: case ACT_CA_CSV:
......
...@@ -137,6 +137,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) { ...@@ -137,6 +137,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
return "SingleTypeConstraint"; return "SingleTypeConstraint";
case ACT_CT_WCOMPS: case ACT_CT_WCOMPS:
return "MultipleTypeConstraints"; return "MultipleTypeConstraints";
case ACT_CT_CTDBY:
return "UserDefinedConstraint";
case ACT_CA_SET: case ACT_CA_SET:
return "SET"; return "SET";
case ACT_CA_CRC: case ACT_CA_CRC:
......
...@@ -25,6 +25,7 @@ typedef struct asn1p_constraint_s { ...@@ -25,6 +25,7 @@ typedef struct asn1p_constraint_s {
ACT_CT_FROM, /* FROM constraint type */ ACT_CT_FROM, /* FROM constraint type */
ACT_CT_WCOMP, /* WITH COMPONENT */ ACT_CT_WCOMP, /* WITH COMPONENT */
ACT_CT_WCOMPS, /* WITH COMPONENTS */ ACT_CT_WCOMPS, /* WITH COMPONENTS */
ACT_CT_CTDBY, /* CONSTRAINED BY */
/* /*
* Arrays of constraints. * Arrays of constraints.
*/ */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -269,7 +269,7 @@ CHOICE return TOK_CHOICE; ...@@ -269,7 +269,7 @@ CHOICE return TOK_CHOICE;
CLASS return TOK_CLASS; CLASS return TOK_CLASS;
COMPONENT return TOK_COMPONENT; COMPONENT return TOK_COMPONENT;
COMPONENTS return TOK_COMPONENTS; COMPONENTS return TOK_COMPONENTS;
CONSRAINED return TOK_CONSTRAINED; CONSTRAINED return TOK_CONSTRAINED;
CONTAINING return TOK_CONTAINING; CONTAINING return TOK_CONTAINING;
DEFAULT return TOK_DEFAULT; DEFAULT return TOK_DEFAULT;
DEFINED { DEFINED {
......
This diff is collapsed.
...@@ -1388,12 +1388,11 @@ DefinedValue: ...@@ -1388,12 +1388,11 @@ DefinedValue:
Opaque: Opaque:
TOK_opaque { TOK_opaque {
$$.len = $1.len + 2; $$.len = $1.len + 1;
$$.buf = malloc($$.len + 1); $$.buf = malloc($$.len + 1);
checkmem($$.buf); checkmem($$.buf);
$$.buf[0] = '{'; $$.buf[0] = '{';
$$.buf[1] = ' '; memcpy($$.buf + 1, $1.buf, $1.len);
memcpy($$.buf + 2, $1.buf, $1.len);
$$.buf[$$.len] = '\0'; $$.buf[$$.len] = '\0';
free($1.buf); free($1.buf);
} }
...@@ -1623,6 +1622,15 @@ ConstraintSubtypeElement: ...@@ -1623,6 +1622,15 @@ ConstraintSubtypeElement:
| WithComponents { | WithComponents {
$$ = $1; $$ = $1;
} }
| TOK_CONSTRAINED TOK_BY '{'
{ asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = ACT_CT_CTDBY;
$$->value = asn1p_value_frombuf($5.buf, $5.len, 0);
checkmem($$->value);
$$->value->type = ATV_UNPARSED;
}
; ;
ConstraintRangeSpec: ConstraintRangeSpec:
......
...@@ -322,6 +322,11 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -322,6 +322,11 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) {
case ACT_CT_WCOMP: case ACT_CT_WCOMP:
case ACT_CT_WCOMPS: case ACT_CT_WCOMPS:
printf("???"); printf("???");
case ACT_CT_CTDBY:
printf("CONSTRAINED BY ");
assert(ct->value->type == ATV_UNPARSED);
fwrite(ct->value->value.string.buf,
1, ct->value->value.string.size, stdout);
break; break;
case ACT_CA_SET: symno++; case ACT_CA_SET: symno++;
case ACT_CA_CRC: symno++; case ACT_CA_CRC: symno++;
......
...@@ -22,7 +22,7 @@ EXTENSION-ATTRIBUTE ::= CLASS { ...@@ -22,7 +22,7 @@ EXTENSION-ATTRIBUTE ::= CLASS {
} WITH SYNTAX {&Type IDENTIFIED BY &id} } WITH SYNTAX {&Type IDENTIFIED BY &id}
terminal-type EXTENSION-ATTRIBUTE ::= { TerminalType IDENTIFIED BY 23} terminal-type EXTENSION-ATTRIBUTE ::= {TerminalType IDENTIFIED BY 23}
ExtensionAttribute ::= SEQUENCE { ExtensionAttribute ::= SEQUENCE {
extension-attribute-type [0] IMPLICIT EXTENSION-ATTRIBUTE.&id ({ExtensionAttributeTable}), extension-attribute-type [0] IMPLICIT EXTENSION-ATTRIBUTE.&id ({ExtensionAttributeTable}),
......
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .79
ModuleTestConstrainedBy
{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 79 }
DEFINITIONS ::=
BEGIN
Type ::= SEQUENCE {
int INTEGER,
...
} (CONSTRAINED BY { -- nothing -- })
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