reorganized parsing around constraints
diff --git a/tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pfcompound-names b/tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pfcompound-names
index ccf82a8..8b16767 100644
--- a/tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pfcompound-names
+++ b/tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pfcompound-names
@@ -7,41 +7,41 @@
/*** <<< DEPS [Flag] >>> ***/
-typedef enum Flag_16P0__field {
- Flag_16P0__field_red = 0,
- Flag_16P0__field_green = 1,
- Flag_16P0__field_blue = 5
-} e_Flag_16P0__field;
-typedef enum Flag_16P1__field {
- Flag_16P1__field_red = 3,
- Flag_16P1__field_green = 4,
- Flag_16P1__field_blue = 5
-} e_Flag_16P1__field;
+typedef enum Flag_15P0__field {
+ Flag_15P0__field_red = 0,
+ Flag_15P0__field_green = 1,
+ Flag_15P0__field_blue = 5
+} e_Flag_15P0__field;
+typedef enum Flag_15P1__field {
+ Flag_15P1__field_red = 3,
+ Flag_15P1__field_green = 4,
+ Flag_15P1__field_blue = 5
+} e_Flag_15P1__field;
/*** <<< TYPE-DECLS [Flag] >>> ***/
-typedef struct Flag_16P0 {
+typedef struct Flag_15P0 {
long *field /* DEFAULT 5 */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
-} Flag_16P0_t;
-typedef struct Flag_16P1 {
+} Flag_15P0_t;
+typedef struct Flag_15P1 {
long *field /* DEFAULT 5 */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
-} Flag_16P1_t;
+} Flag_15P1_t;
/*** <<< FUNC-DECLS [Flag] >>> ***/
-extern asn_TYPE_descriptor_t asn_DEF_Flag_16P0;
-extern asn_SEQUENCE_specifics_t asn_SPC_Flag_16P0_specs_1;
-extern asn_TYPE_member_t asn_MBR_Flag_16P0_1[1];
+extern asn_TYPE_descriptor_t asn_DEF_Flag_15P0;
+extern asn_SEQUENCE_specifics_t asn_SPC_Flag_15P0_specs_1;
+extern asn_TYPE_member_t asn_MBR_Flag_15P0_1[1];
/* extern asn_TYPE_descriptor_t asn_DEF_field_7; // (Use -fall-defs-global to expose) */
-extern asn_TYPE_descriptor_t asn_DEF_Flag_16P1;
-extern asn_SEQUENCE_specifics_t asn_SPC_Flag_16P1_specs_6;
-extern asn_TYPE_member_t asn_MBR_Flag_16P1_6[1];
+extern asn_TYPE_descriptor_t asn_DEF_Flag_15P1;
+extern asn_SEQUENCE_specifics_t asn_SPC_Flag_15P1_specs_6;
+extern asn_TYPE_member_t asn_MBR_Flag_15P1_6[1];
/*** <<< CODE [Flag] >>> ***/
@@ -70,8 +70,8 @@
return (*st == 5);
}
}
-asn_TYPE_member_t asn_MBR_Flag_16P0_1[] = {
- { ATF_POINTER, 1, offsetof(struct Flag_16P0, field),
+asn_TYPE_member_t asn_MBR_Flag_15P0_1[] = {
+ { ATF_POINTER, 1, offsetof(struct Flag_15P0, field),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
@@ -83,37 +83,37 @@
.name = "field"
},
};
-static const ber_tlv_tag_t asn_DEF_Flag_16P0_tags_1[] = {
+static const ber_tlv_tag_t asn_DEF_Flag_15P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
-static const asn_TYPE_tag2member_t asn_MAP_Flag_16P0_tag2el_1[] = {
+static const asn_TYPE_tag2member_t asn_MAP_Flag_15P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* field */
};
-asn_SEQUENCE_specifics_t asn_SPC_Flag_16P0_specs_1 = {
- sizeof(struct Flag_16P0),
- offsetof(struct Flag_16P0, _asn_ctx),
- .tag2el = asn_MAP_Flag_16P0_tag2el_1,
+asn_SEQUENCE_specifics_t asn_SPC_Flag_15P0_specs_1 = {
+ sizeof(struct Flag_15P0),
+ offsetof(struct Flag_15P0, _asn_ctx),
+ .tag2el = asn_MAP_Flag_15P0_tag2el_1,
.tag2el_count = 1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
-asn_TYPE_descriptor_t asn_DEF_Flag_16P0 = {
+asn_TYPE_descriptor_t asn_DEF_Flag_15P0 = {
"Flag",
"Flag",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
- asn_DEF_Flag_16P0_tags_1,
- sizeof(asn_DEF_Flag_16P0_tags_1)
- /sizeof(asn_DEF_Flag_16P0_tags_1[0]), /* 1 */
- asn_DEF_Flag_16P0_tags_1, /* Same as above */
- sizeof(asn_DEF_Flag_16P0_tags_1)
- /sizeof(asn_DEF_Flag_16P0_tags_1[0]), /* 1 */
+ asn_DEF_Flag_15P0_tags_1,
+ sizeof(asn_DEF_Flag_15P0_tags_1)
+ /sizeof(asn_DEF_Flag_15P0_tags_1[0]), /* 1 */
+ asn_DEF_Flag_15P0_tags_1, /* Same as above */
+ sizeof(asn_DEF_Flag_15P0_tags_1)
+ /sizeof(asn_DEF_Flag_15P0_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
- asn_MBR_Flag_16P0_1,
+ asn_MBR_Flag_15P0_1,
1, /* Elements count */
- &asn_SPC_Flag_16P0_specs_1 /* Additional specs */
+ &asn_SPC_Flag_15P0_specs_1 /* Additional specs */
};
static int asn_DFL_7_set_5(int set_value, void **sptr) {
@@ -174,8 +174,8 @@
&asn_SPC_field_specs_7 /* Additional specs */
};
-asn_TYPE_member_t asn_MBR_Flag_16P1_6[] = {
- { ATF_POINTER, 1, offsetof(struct Flag_16P1, field),
+asn_TYPE_member_t asn_MBR_Flag_15P1_6[] = {
+ { ATF_POINTER, 1, offsetof(struct Flag_15P1, field),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
.tag_mode = 0,
.type = &asn_DEF_field_7,
@@ -187,37 +187,37 @@
.name = "field"
},
};
-static const ber_tlv_tag_t asn_DEF_Flag_16P1_tags_6[] = {
+static const ber_tlv_tag_t asn_DEF_Flag_15P1_tags_6[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
-static const asn_TYPE_tag2member_t asn_MAP_Flag_16P1_tag2el_6[] = {
+static const asn_TYPE_tag2member_t asn_MAP_Flag_15P1_tag2el_6[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)), 0, 0, 0 } /* field */
};
-asn_SEQUENCE_specifics_t asn_SPC_Flag_16P1_specs_6 = {
- sizeof(struct Flag_16P1),
- offsetof(struct Flag_16P1, _asn_ctx),
- .tag2el = asn_MAP_Flag_16P1_tag2el_6,
+asn_SEQUENCE_specifics_t asn_SPC_Flag_15P1_specs_6 = {
+ sizeof(struct Flag_15P1),
+ offsetof(struct Flag_15P1, _asn_ctx),
+ .tag2el = asn_MAP_Flag_15P1_tag2el_6,
.tag2el_count = 1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
-asn_TYPE_descriptor_t asn_DEF_Flag_16P1 = {
+asn_TYPE_descriptor_t asn_DEF_Flag_15P1 = {
"Flag",
"Flag",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
- asn_DEF_Flag_16P1_tags_6,
- sizeof(asn_DEF_Flag_16P1_tags_6)
- /sizeof(asn_DEF_Flag_16P1_tags_6[0]), /* 1 */
- asn_DEF_Flag_16P1_tags_6, /* Same as above */
- sizeof(asn_DEF_Flag_16P1_tags_6)
- /sizeof(asn_DEF_Flag_16P1_tags_6[0]), /* 1 */
+ asn_DEF_Flag_15P1_tags_6,
+ sizeof(asn_DEF_Flag_15P1_tags_6)
+ /sizeof(asn_DEF_Flag_15P1_tags_6[0]), /* 1 */
+ asn_DEF_Flag_15P1_tags_6, /* Same as above */
+ sizeof(asn_DEF_Flag_15P1_tags_6)
+ /sizeof(asn_DEF_Flag_15P1_tags_6[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
- asn_MBR_Flag_16P1_6,
+ asn_MBR_Flag_15P1_6,
1, /* Elements count */
- &asn_SPC_Flag_16P1_specs_6 /* Additional specs */
+ &asn_SPC_Flag_15P1_specs_6 /* Additional specs */
};
@@ -227,7 +227,7 @@
/*** <<< TYPE-DECLS [IntegerColorFlag] >>> ***/
-typedef Flag_16P0_t IntegerColorFlag_t;
+typedef Flag_15P0_t IntegerColorFlag_t;
/*** <<< FUNC-DECLS [IntegerColorFlag] >>> ***/
@@ -243,7 +243,7 @@
/*** <<< CODE [IntegerColorFlag] >>> ***/
/*
- * This type is implemented using Flag_16P0,
+ * This type is implemented using Flag_15P0,
* so here we adjust the DEF accordingly.
*/
@@ -265,9 +265,9 @@
/sizeof(asn_DEF_IntegerColorFlag_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
- asn_MBR_Flag_16P0_1,
+ asn_MBR_Flag_15P0_1,
1, /* Elements count */
- &asn_SPC_Flag_16P0_specs_1 /* Additional specs */
+ &asn_SPC_Flag_15P0_specs_1 /* Additional specs */
};
@@ -277,7 +277,7 @@
/*** <<< TYPE-DECLS [EnumeratedColorFlag] >>> ***/
-typedef Flag_16P1_t EnumeratedColorFlag_t;
+typedef Flag_15P1_t EnumeratedColorFlag_t;
/*** <<< FUNC-DECLS [EnumeratedColorFlag] >>> ***/
@@ -293,7 +293,7 @@
/*** <<< CODE [EnumeratedColorFlag] >>> ***/
/*
- * This type is implemented using Flag_16P1,
+ * This type is implemented using Flag_15P1,
* so here we adjust the DEF accordingly.
*/
@@ -315,8 +315,8 @@
/sizeof(asn_DEF_EnumeratedColorFlag_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
- asn_MBR_Flag_16P1_6,
+ asn_MBR_Flag_15P1_6,
1, /* Elements count */
- &asn_SPC_Flag_16P1_specs_6 /* Additional specs */
+ &asn_SPC_Flag_15P1_specs_6 /* Additional specs */
};
diff --git a/tests/tests-asn1c-compiler/149-with-components-SE.asn1.-E b/tests/tests-asn1c-compiler/149-with-components-SE.asn1.-E
index 0a7073d..e20e6cd 100644
--- a/tests/tests-asn1c-compiler/149-with-components-SE.asn1.-E
+++ b/tests/tests-asn1c-compiler/149-with-components-SE.asn1.-E
@@ -7,6 +7,6 @@
IdentifiedRegion ( WITH COMPONENTS { countryOnly(Canada) }),
IdentifiedRegion ( WITH COMPONENTS { countryOnly(Mexico) }),
IdentifiedRegion ( WITH COMPONENTS { countryOnly(USA) })
- })) }), canRequestRollover ( NULL), encryptionKey ABSENT, verifyKeyIndicator (WITH COMPONENTS { verificationKey (WITH COMPONENTS { ecdsaNistP256 (WITH COMPONENTS { compressed-y-0, compressed-y-1 }) }) }) }) })
+ })) }), canRequestRollover (NULL), encryptionKey ABSENT, verifyKeyIndicator (WITH COMPONENTS { verificationKey (WITH COMPONENTS { ecdsaNistP256 (WITH COMPONENTS { compressed-y-0, compressed-y-1 }) }) }) }) })
END
diff --git a/tests/tests-asn1c-compiler/151-per-b2110-OK.asn1 b/tests/tests-asn1c-compiler/151-per-b2110-OK.asn1
new file mode 100644
index 0000000..8706d86
--- /dev/null
+++ b/tests/tests-asn1c-compiler/151-per-b2110-OK.asn1
@@ -0,0 +1,18 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .151
+
+ModulePerEffectiveConstraint
+ { iso org(3) dod(6) internet(1) private(4) enterprise(1)
+ spelio(9363) software(1) asn1c(5) test(1) 151 }
+DEFINITIONS ::= BEGIN
+
+ -- B.2.1.10
+ -- Effective constraint: SIZE(3..20) and FROM("A".."K")
+ B ::= VisibleString (SIZE (20) INTERSECTION FROM ("A".."F")
+ UNION SIZE (3) INTERSECTION FROM ("F".."K"))
+
+END
diff --git a/tests/tests-asn1c-compiler/151-per-b2110-OK.asn1.-EFprint-constraints b/tests/tests-asn1c-compiler/151-per-b2110-OK.asn1.-EFprint-constraints
new file mode 100644
index 0000000..09b56f8
--- /dev/null
+++ b/tests/tests-asn1c-compiler/151-per-b2110-OK.asn1.-EFprint-constraints
@@ -0,0 +1,12 @@
+ModulePerEffectiveConstraint { iso org(3) dod(6) internet(1) private(4)
+ enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 151 }
+DEFINITIONS ::=
+BEGIN
+
+B ::= VisibleString (SIZE(20) ^ FROM("A".."F") | SIZE(3) ^ FROM("F".."K"))
+-- Combined constraints: (SIZE(20) ^ FROM("A".."F") | SIZE(3) ^ FROM("F".."K"))
+-- Practical constraints (B): (MIN..MAX) (SIZE(3 | 20)) (FROM("A".."K"))
+-- OER-visible constraints (B): (MIN..MAX) (SIZE(3 | 20))
+-- PER-visible constraints (B): (MIN..MAX) (SIZE(3 | 20)) (FROM("A".."K"))
+
+END
diff --git a/tests/tests-asn1c-compiler/152-value-and-type-references-OK.asn1 b/tests/tests-asn1c-compiler/152-value-and-type-references-OK.asn1
new file mode 100644
index 0000000..fcbd527
--- /dev/null
+++ b/tests/tests-asn1c-compiler/152-value-and-type-references-OK.asn1
@@ -0,0 +1,43 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .152
+
+ModuleValueAndTypeReferences
+ { iso org(3) dod(6) internet(1) private(4) enterprise(1)
+ spelio(9363) software(1) asn1c(5) test(1) 152 }
+DEFINITIONS ::= BEGIN
+
+ value INTEGER ::= 3
+
+ valueAssignment3 INTEGER ::= value
+ valueAssignment4 INTEGER ::= MOD-CAPITALS.value4
+
+ Foo ::= Extension {{CAPS.SomeType}}
+ Bar ::= Extension {{Uppercase.SomeType}}
+
+ Extension {Foo} ::= SEQUENCE {
+ }
+
+ MTYPE ::= CLASS {
+ &id INTEGER UNIQUE,
+ &Type
+ } WITH SYNTAX {&Type IDENTIFIED BY &id}
+
+ MessageFrame ::= SEQUENCE {
+ messageIdE MTYPE.&id,
+ messageIdF MTYPE.&id({MessageTypes}),
+ valueE MTYPE.&Type,
+ valueF MTYPE.&Type({MessageTypes}{@.messageId})
+ }
+
+END
+
+MOD-CAPITALS
+ { iso org(3) dod(6) internet(1) private(4) enterprise(1)
+ spelio(9363) software(1) asn1c(5) test(1) 152 1 }
+DEFINITIONS ::= BEGIN
+ value4 INTEGER ::= 4
+END
diff --git a/tests/tests-asn1c-compiler/152-value-and-type-references-OK.asn1.-EF b/tests/tests-asn1c-compiler/152-value-and-type-references-OK.asn1.-EF
new file mode 100644
index 0000000..ac83aa5
--- /dev/null
+++ b/tests/tests-asn1c-compiler/152-value-and-type-references-OK.asn1.-EF
@@ -0,0 +1,40 @@
+ModuleValueAndTypeReferences { iso org(3) dod(6) internet(1) private(4)
+ enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 152 }
+DEFINITIONS ::=
+BEGIN
+
+value INTEGER ::= 3
+
+valueAssignment3 INTEGER ::= 3
+
+valueAssignment4 INTEGER ::= 4
+
+Foo ::= Extension{ { CAPS.SomeType}}
+
+Bar ::= Extension{ { Uppercase.SomeType}}
+
+Extension{Foo} ::= SEQUENCE { }
+
+MTYPE ::= CLASS {
+ &id INTEGER UNIQUE,
+ &Type ANY
+} WITH SYNTAX {&Type IDENTIFIED BY &id}
+
+
+MessageFrame ::= SEQUENCE {
+ messageIdE MTYPE.&id,
+ messageIdF MTYPE.&id ({MessageTypes}),
+ valueE MTYPE.&Type,
+ valueF MTYPE.&Type ({MessageTypes}{@.messageId})
+}
+
+END
+
+MOD-CAPITALS { iso org(3) dod(6) internet(1) private(4) enterprise(1)
+ spelio(9363) software(1) asn1c(5) test(1) 152 1 }
+DEFINITIONS ::=
+BEGIN
+
+value4 INTEGER ::= 4
+
+END