=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/asn1_compile/Attic/parse.y,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/asn1_compile/Attic/parse.y 2003/05/11 21:36:33 1.1 +++ src/usr.bin/asn1_compile/Attic/parse.y 2005/10/16 18:56:35 1.2 @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $KTH: parse.y,v 1.19 2001/09/27 16:21:47 assar Exp $ */ +/* $KTH: parse.y,v 1.23 2004/10/13 17:41:48 lha Exp $ */ %{ #ifdef HAVE_CONFIG_H @@ -45,7 +45,7 @@ #include "gen_locl.h" /* -RCSID("$KTH: parse.y,v 1.19 2001/09/27 16:21:47 assar Exp $"); +RCSID("$KTH: parse.y,v 1.23 2004/10/13 17:41:48 lha Exp $"); */ static Type *new_type (Typetype t); @@ -60,12 +60,15 @@ char *name; Type *type; Member *member; + char *defval; } -%token INTEGER SEQUENCE OF OCTET STRING GeneralizedTime GeneralString +%token INTEGER SEQUENCE CHOICE OF OCTET STRING GeneralizedTime GeneralString %token BIT APPLICATION OPTIONAL EEQUAL TBEGIN END DEFINITIONS ENUMERATED -%token EXTERNAL -%token DOTDOT +%token UTF8String NULLTYPE +%token EXTERNAL DEFAULT +%token DOTDOT DOTDOTDOT +%token BOOLEAN %token IMPORTS FROM %token OBJECT IDENTIFIER %token IDENT @@ -73,8 +76,10 @@ %type constant optional2 %type type -%type memberdecls memberdecl bitdecls bitdecl +%type memberdecls memberdecl memberdeclstart bitdecls bitdecl +%type defvalue + %start envelope %% @@ -147,6 +152,8 @@ } | OCTET STRING { $$ = new_type(TOctetString); } | GeneralString { $$ = new_type(TGeneralString); } + | UTF8String { $$ = new_type(TUTF8String); } + | NULLTYPE { $$ = new_type(TNull); } | GeneralizedTime { $$ = new_type(TGeneralizedTime); } | SEQUENCE OF type { @@ -158,6 +165,11 @@ $$ = new_type(TSequence); $$->members = $3; } + | CHOICE '{' memberdecls '}' + { + $$ = new_type(TChoice); + $$->members = $3; + } | BIT STRING '{' bitdecls '}' { $$ = new_type(TBitString); @@ -178,32 +190,51 @@ $$->subtype = $5; $$->application = $3; } + | BOOLEAN { $$ = new_type(TBoolean); } ; memberdecls : { $$ = NULL; } | memberdecl { $$ = $1; } + | memberdecls ',' DOTDOTDOT { $$ = $1; } | memberdecls ',' memberdecl { $$ = $1; append($$, $3); } ; -memberdecl : IDENT '[' constant ']' type optional2 +memberdeclstart : IDENT '[' constant ']' type { $$ = malloc(sizeof(*$$)); $$->name = $1; $$->gen_name = strdup($1); output_name ($$->gen_name); $$->val = $3; - $$->optional = $6; + $$->optional = 0; + $$->defval = NULL; $$->type = $5; $$->next = $$->prev = $$; } ; -optional2 : { $$ = 0; } - | OPTIONAL { $$ = 1; } + +memberdecl : memberdeclstart optional2 + { $1->optional = $2 ; $$ = $1; } + | memberdeclstart defvalue + { $1->defval = $2 ; $$ = $1; } + | memberdeclstart + { $$ = $1; } ; + +optional2 : OPTIONAL { $$ = 1; } + ; + +defvalue : DEFAULT constant + { asprintf(&$$, "%d", $2); } + | DEFAULT '"' IDENT '"' + { $$ = strdup ($3); } + ; + bitdecls : { $$ = NULL; } | bitdecl { $$ = $1; } + | bitdecls ',' DOTDOTDOT { $$ = $1; } | bitdecls ',' bitdecl { $$ = $1; append($$, $3); } ; @@ -221,6 +252,7 @@ ; constant : CONSTANT { $$ = $1; } + | '-' CONSTANT { $$ = -$2; } | IDENT { Symbol *s = addsym($1); if(s->stype != SConstant)