Commit bf979156 authored by Lev Walkin's avatar Lev Walkin

parse a variant of value constraint

parent 0c68645c
...@@ -2664,7 +2664,7 @@ YY_RULE_SETUP ...@@ -2664,7 +2664,7 @@ YY_RULE_SETUP
#line 161 "asn1p_l.l" #line 161 "asn1p_l.l"
{ {
fprintf(stderr, fprintf(stderr,
"ASN.1 Parser syncronization failure: " "ASN.1 Parser synchronization failure: "
"\"%s\" at line %d must not appear " "\"%s\" at line %d must not appear "
"inside value definition\n", "inside value definition\n",
asn1p_text, asn1p_lineno); asn1p_text, asn1p_lineno);
......
...@@ -160,7 +160,7 @@ WSP [\t\r\v\f\n ] ...@@ -160,7 +160,7 @@ WSP [\t\r\v\f\n ]
"::=" { "::=" {
fprintf(stderr, fprintf(stderr,
"ASN.1 Parser syncronization failure: " "ASN.1 Parser synchronization failure: "
"\"%s\" at line %d must not appear " "\"%s\" at line %d must not appear "
"inside value definition\n", "inside value definition\n",
yytext, yylineno); yytext, yylineno);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -350,6 +350,7 @@ static asn1p_module_t *currentModule; ...@@ -350,6 +350,7 @@ static asn1p_module_t *currentModule;
%type <a_type> BasicTypeId_UniverationCompatible %type <a_type> BasicTypeId_UniverationCompatible
%type <a_type> BasicString %type <a_type> BasicString
%type <tv_opaque> Opaque %type <tv_opaque> Opaque
%type <tv_opaque> OpaqueFirstToken
%type <a_tag> Tag /* [UNIVERSAL 0] IMPLICIT */ %type <a_tag> Tag /* [UNIVERSAL 0] IMPLICIT */
%type <a_tag> TagClass TagTypeValue TagPlicit %type <a_tag> TagClass TagTypeValue TagPlicit
%type <a_tag> optTag /* [UNIVERSAL 0] IMPLICIT */ %type <a_tag> optTag /* [UNIVERSAL 0] IMPLICIT */
...@@ -1566,7 +1567,7 @@ Value: ...@@ -1566,7 +1567,7 @@ Value:
$$->value.choice_identifier.identifier = $1; $$->value.choice_identifier.identifier = $1;
$$->value.choice_identifier.value = $3; $$->value.choice_identifier.value = $3;
} }
| '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ { | '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque {
$$ = asn1p_value_frombuf($3.buf, $3.len, 0); $$ = asn1p_value_frombuf($3.buf, $3.len, 0);
checkmem($$); checkmem($$);
$$->type = ATV_UNPARSED; $$->type = ATV_UNPARSED;
...@@ -1654,15 +1655,15 @@ RestrictedCharacterStringValue: ...@@ -1654,15 +1655,15 @@ RestrictedCharacterStringValue:
; ;
Opaque: Opaque:
TOK_opaque { OpaqueFirstToken {
$$.len = $1.len + 1; $$.len = $1.len + 1;
$$.buf = malloc($$.len + 1); $$.buf = malloc(1 + $$.len + 1);
checkmem($$.buf); checkmem($$.buf);
$$.buf[0] = '{'; $$.buf[0] = '{';
memcpy($$.buf + 1, $1.buf, $1.len); memcpy($$.buf + 1, $1.buf, $1.len);
$$.buf[$$.len] = '\0'; $$.buf[$$.len] = '\0';
free($1.buf); free($1.buf);
} }
| Opaque TOK_opaque { | Opaque TOK_opaque {
int newsize = $1.len + $2.len; int newsize = $1.len + $2.len;
char *p = malloc(newsize + 1); char *p = malloc(newsize + 1);
...@@ -1677,6 +1678,13 @@ Opaque: ...@@ -1677,6 +1678,13 @@ Opaque:
} }
; ;
OpaqueFirstToken:
TOK_opaque
| Identifier {
$$.len = strlen($1);
$$.buf = $1;
};
BasicTypeId: BasicTypeId:
TOK_BOOLEAN { $$ = ASN_BASIC_BOOLEAN; } TOK_BOOLEAN { $$ = ASN_BASIC_BOOLEAN; }
| TOK_NULL { $$ = ASN_BASIC_NULL; } | TOK_NULL { $$ = ASN_BASIC_NULL; }
...@@ -1893,7 +1901,7 @@ SubtypeElements: ...@@ -1893,7 +1901,7 @@ SubtypeElements:
| InnerTypeConstraints /* WITH COMPONENT[S] ... */ | InnerTypeConstraints /* WITH COMPONENT[S] ... */
| PatternConstraint /* PATTERN ... */ | PatternConstraint /* PATTERN ... */
| ValueRange | ValueRange
| '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ { | '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque {
$$ = asn1p_constraint_new(yylineno, currentModule); $$ = asn1p_constraint_new(yylineno, currentModule);
checkmem($$); checkmem($$);
$$->type = ACT_EL_VALUE; $$->type = ACT_EL_VALUE;
......
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .150
ModuleValueWithComponents
{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 150 }
DEFINITIONS ::= BEGIN
EntityType ::= BIT STRING {app (0), enrol (1)} (SIZE (8))
GroupPermissions ::= SEQUENCE {
minChainDepth INTEGER DEFAULT 1,
eeType EntityType DEFAULT {app}
}
EnrolPermissions ::= GroupPermissions (WITH COMPONENTS {
minChainDepth (2),
eeType ({enrol})
})
END
ModuleValueWithComponents { iso org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 150 }
DEFINITIONS ::=
BEGIN
EntityType ::= BIT STRING {
app(0),
enrol(1)
} (SIZE(8))
GroupPermissions ::= SEQUENCE {
minChainDepth INTEGER DEFAULT 1,
eeType EntityType DEFAULT {app}
}
EnrolPermissions ::= GroupPermissions (WITH COMPONENTS { minChainDepth (2), eeType ({enrol}) })
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