groking obsolete syntax

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@953 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2005-08-13 09:07:11 +00:00
parent 931aeede61
commit 5d89c3d031
4 changed files with 1074 additions and 920 deletions

View File

@ -1,7 +1,8 @@
0.9.17: 2005-Aug-11
0.9.17: 2005-Aug-13
* ...
* The obsolete X.208 syntax is handled gracefully now (compound types'
member names are invented on the fly). (Test case 87).
0.9.17: 2005-Aug-07

File diff suppressed because it is too large Load Diff

View File

@ -29,8 +29,8 @@ extern int asn1p_lineno;
*/
static struct AssignedIdentifier *saved_aid;
static asn1p_value_t *
_convert_bitstring2binary(char *str, int base);
static asn1p_value_t *_convert_bitstring2binary(char *str, int base);
static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
#define checkmem(ptr) do { \
if(!(ptr)) \
@ -901,6 +901,11 @@ ComponentType:
| ExtensionAndException {
$$ = $1;
}
| Type optMarker {
$$ = $1;
$$->marker = $2;
_fixup_anonymous_identifier($$);
}
;
AlternativeTypeLists:
@ -924,6 +929,10 @@ AlternativeType:
| ExtensionAndException {
$$ = $1;
}
| Type {
$$ = $1;
_fixup_anonymous_identifier($$);
}
;
ClassDeclaration:
@ -2184,6 +2193,48 @@ _convert_bitstring2binary(char *str, int base) {
return val;
}
/*
* For unnamed types (used in old X.208 compliant modules)
* generate some sort of interim names, to not to force human being to fix
* the specification's compliance to modern ASN.1 standards.
*/
static void
_fixup_anonymous_identifier(asn1p_expr_t *expr) {
char *p;
assert(expr->Identifier == 0);
/*
* Try to figure out the type name
* without going too much into details
*/
expr->Identifier = ASN_EXPR_TYPE2STR(expr->expr_type);
if(expr->reference && expr->reference->comp_count > 0)
expr->Identifier = expr->reference->components[0].name;
fprintf(stderr,
"WARNING: Line %d: expected lower-case member identifier, "
"found an unnamed %s.\n"
"WARNING: Obsolete X.208 syntax detected, "
"please give the member a name.\n",
yylineno, expr->Identifier ? expr->Identifier : "type");
if(!expr->Identifier)
expr->Identifier = "unnamed";
expr->Identifier = strdup(expr->Identifier);
assert(expr->Identifier);
/* Make a lowercase identifier from the type name */
for(p = expr->Identifier; *p; p++) {
switch(*p) {
case 'A' ... 'Z': *p += 32; break;
case ' ': *p = '_'; break;
case '-': *p = '_'; break;
}
}
fprintf(stderr, "NOTE: Assigning temporary identifier \"%s\". "
"Name clash may occur later.\n",
expr->Identifier);
}
extern char *asn1p_text;
int

View File

@ -0,0 +1,29 @@
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .87
ModuleObsoleteSyntax
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 87 }
DEFINITIONS ::=
BEGIN
Tc ::= CHOICE {
INTEGER,
BOOLEAN
}
Ts ::= SET {
INTEGER,
BOOLEAN,
SEQUENCE {
OBJECT IDENTIFIER,
RELATIVE-OID,
Tc
}
}
END