Commit 5c541f11 authored by Lev Walkin's avatar Lev Walkin

PatterConstraint parsing

parent 5bcbda55
...@@ -95,6 +95,10 @@ asn1constraint_compatible(asn1p_expr_type_e expr_type, ...@@ -95,6 +95,10 @@ asn1constraint_compatible(asn1p_expr_type_e expr_type,
default: default:
return 0; return 0;
} }
case ACT_CT_PATTERN:
if(expr_type & ASN_STRING_MASK)
return 1;
return 0;
case ACT_CA_SET: case ACT_CA_SET:
case ACT_CA_CRC: case ACT_CA_CRC:
case ACT_CA_CSV: case ACT_CA_CSV:
......
...@@ -171,6 +171,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) { ...@@ -171,6 +171,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
return "UserDefinedConstraint"; return "UserDefinedConstraint";
case ACT_CT_CTNG: case ACT_CT_CTNG:
return "ContentsConstraint"; return "ContentsConstraint";
case ACT_CT_PATTERN:
return "PatternConstraint";
case ACT_CA_SET: case ACT_CA_SET:
return "SET"; return "SET";
case ACT_CA_CRC: case ACT_CA_CRC:
......
...@@ -27,6 +27,7 @@ typedef struct asn1p_constraint_s { ...@@ -27,6 +27,7 @@ typedef struct asn1p_constraint_s {
ACT_CT_WCOMPS, /* WITH COMPONENTS */ ACT_CT_WCOMPS, /* WITH COMPONENTS */
ACT_CT_CTDBY, /* CONSTRAINED BY */ ACT_CT_CTDBY, /* CONSTRAINED BY */
ACT_CT_CTNG, /* CONTAINING Type */ ACT_CT_CTNG, /* CONTAINING Type */
ACT_CT_PATTERN, /* PATTERN Value */
/* /*
* Arrays of constraints. * Arrays of constraints.
*/ */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -325,6 +325,7 @@ static asn1p_module_t *currentModule; ...@@ -325,6 +325,7 @@ static asn1p_module_t *currentModule;
%type <a_constr> UserDefinedConstraint %type <a_constr> UserDefinedConstraint
%type <a_constr> TableConstraint %type <a_constr> TableConstraint
%type <a_constr> ContentsConstraint %type <a_constr> ContentsConstraint
%type <a_constr> PatternConstraint
%type <a_constr> InnerTypeConstraint %type <a_constr> InnerTypeConstraint
%type <a_constr> WithComponentsList %type <a_constr> WithComponentsList
%type <a_constr> WithComponentsElement %type <a_constr> WithComponentsElement
...@@ -1850,6 +1851,25 @@ ConstraintSubtypeElement: ...@@ -1850,6 +1851,25 @@ ConstraintSubtypeElement:
| InnerTypeConstraint { | InnerTypeConstraint {
$$ = $1; $$ = $1;
} }
| PatternConstraint {
$$ = $1;
}
;
PatternConstraint:
TOK_PATTERN TOK_cstring {
$$ = asn1p_constraint_new(yylineno);
$$->type = ACT_CT_PATTERN;
$$->value = asn1p_value_frombuf($2.buf, $2.len, 0);
}
| TOK_PATTERN Identifier {
asn1p_ref_t *ref;
$$ = asn1p_constraint_new(yylineno);
$$->type = ACT_CT_PATTERN;
ref = asn1p_ref_new(yylineno);
asn1p_ref_add_component(ref, $2, RLT_lowercase);
$$->value = asn1p_value_fromref(ref, 0);
}
; ;
ConstraintSpec: ConstraintSpec:
......
...@@ -368,6 +368,11 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -368,6 +368,11 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) {
flags, 1); flags, 1);
printf(")"); printf(")");
break; break;
case ACT_CT_PATTERN:
printf("(PATTERN ");
asn1print_value(ct->value, flags);
printf(")");
break;
case ACT_CA_SET: symno++; case ACT_CA_SET: symno++;
case ACT_CA_CRC: symno++; case ACT_CA_CRC: symno++;
case ACT_CA_CSV: symno++; case ACT_CA_CSV: symno++;
......
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .122
ModulePatternConstraint
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 122 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Language ::= VisibleString (FROM ("a".."z" | "A".."Z" | "-" | "0".."9"))
(PATTERN "[a-zA-Z]#(1,8)(-[a-zA-Z0-9]#(1,8))*")
PatternByRef1 ::= VisibleString (PATTERN refPattern1)
PatternByRef2 ::= VisibleString (PATTERN refPattern2)
refPattern1 UniversalString ::= "[a-zA-Z]#(1,8)(-[a-zA-Z0-9]#(1,8))*"
refPattern2 UTF8String ::= "[a-zA-Z]#(1,8)(-[a-zA-Z0-9]#(1,8))*"
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