PatterConstraint parsing

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1256 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2006-10-18 18:40:14 +00:00
parent 8c0a8fe89e
commit 8cc3f74728
7 changed files with 907 additions and 811 deletions

View File

@ -95,6 +95,10 @@ asn1constraint_compatible(asn1p_expr_type_e expr_type,
default:
return 0;
}
case ACT_CT_PATTERN:
if(expr_type & ASN_STRING_MASK)
return 1;
return 0;
case ACT_CA_SET:
case ACT_CA_CRC:
case ACT_CA_CSV:

View File

@ -171,6 +171,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
return "UserDefinedConstraint";
case ACT_CT_CTNG:
return "ContentsConstraint";
case ACT_CT_PATTERN:
return "PatternConstraint";
case ACT_CA_SET:
return "SET";
case ACT_CA_CRC:

View File

@ -27,6 +27,7 @@ typedef struct asn1p_constraint_s {
ACT_CT_WCOMPS, /* WITH COMPONENTS */
ACT_CT_CTDBY, /* CONSTRAINED BY */
ACT_CT_CTNG, /* CONTAINING Type */
ACT_CT_PATTERN, /* PATTERN Value */
/*
* Arrays of constraints.
*/

File diff suppressed because it is too large Load Diff

View File

@ -325,6 +325,7 @@ static asn1p_module_t *currentModule;
%type <a_constr> UserDefinedConstraint
%type <a_constr> TableConstraint
%type <a_constr> ContentsConstraint
%type <a_constr> PatternConstraint
%type <a_constr> InnerTypeConstraint
%type <a_constr> WithComponentsList
%type <a_constr> WithComponentsElement
@ -1850,6 +1851,25 @@ ConstraintSubtypeElement:
| InnerTypeConstraint {
$$ = $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:

View File

@ -368,6 +368,11 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) {
flags, 1);
printf(")");
break;
case ACT_CT_PATTERN:
printf("(PATTERN ");
asn1print_value(ct->value, flags);
printf(")");
break;
case ACT_CA_SET: symno++;
case ACT_CA_CRC: symno++;
case ACT_CA_CSV: symno++;

23
tests/122-pattern-OK.asn1 Normal file
View File

@ -0,0 +1,23 @@
-- 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