*** empty log message ***

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1183 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2006-09-14 10:35:20 +00:00
parent cb9238215d
commit d3420d3586
6 changed files with 1344 additions and 1310 deletions

View File

@ -50,16 +50,16 @@ typedef struct asn1p_module_s {
*/
asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */
/*
* List of everything that this module IMPORTS.
*/
TQ_HEAD(struct asn1p_xports_s) imports;
/*
* List of everything that this module EXPORTS.
*/
TQ_HEAD(struct asn1p_xports_s) exports;
/*
* List of everything that this module IMPORTS.
*/
TQ_HEAD(struct asn1p_xports_s) imports;
/*
* List of everything that this module defines itself.
*/

File diff suppressed because it is too large Load Diff

View File

@ -245,7 +245,7 @@
#ifndef YYSTYPE
#line 72 "asn1p_y.y"
#line 85 "asn1p_y.y"
typedef union {
asn1p_t *a_grammar;
asn1p_module_flags_e a_module_flags;

View File

@ -61,6 +61,19 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
} \
} while(0)
#ifdef AL_IMPORT
#error AL_IMPORT DEFINED ELSEWHERE!
#endif
#define AL_IMPORT(to,where,from,field) do { \
if(!(from)) break; \
while(TQ_FIRST(&((from)->where))) { \
TQ_ADD(&((to)->where), \
TQ_REMOVE(&((from)->where), field), \
field); \
} \
assert(TQ_FIRST(&((from)->where)) == 0); \
} while(0)
%}
@ -223,13 +236,16 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
* Types defined herein.
*/
%type <a_grammar> ModuleList
%type <a_module> ModuleSpecification
%type <a_module> ModuleSpecificationBody
%type <a_module> ModuleSpecificationElement
%type <a_module> optModuleSpecificationBody /* Optional */
%type <a_module_flags> optModuleSpecificationFlags
%type <a_module_flags> ModuleSpecificationFlags /* Set of FL */
%type <a_module_flags> ModuleSpecificationFlag /* Single FL */
%type <a_module> ModuleDefinition
%type <a_module> ModuleBody
%type <a_module> AssignmentList
%type <a_module> Assignment
%type <a_module> optModuleBody /* Optional */
%type <a_module_flags> optModuleDefinitionFlags
%type <a_module_flags> ModuleDefinitionFlags /* Set of FL */
%type <a_module_flags> ModuleDefinitionFlag /* Single FL */
%type <a_module> optImports
%type <a_module> optExports
%type <a_module> ImportsDefinition
%type <a_module> ImportsBundleSet
%type <a_xports> ImportsBundle
@ -330,12 +346,12 @@ ParsedGrammar:
;
ModuleList:
ModuleSpecification {
ModuleDefinition {
$$ = asn1p_new();
checkmem($$);
TQ_ADD(&($$->modules), $1, mod_next);
}
| ModuleList ModuleSpecification {
| ModuleList ModuleDefinition {
$$ = $1;
TQ_ADD(&($$->modules), $2, mod_next);
}
@ -351,11 +367,11 @@ ModuleList:
* === EOF ===
*/
ModuleSpecification:
ModuleDefinition:
TypeRefName optObjectIdentifier TOK_DEFINITIONS
optModuleSpecificationFlags
optModuleDefinitionFlags
TOK_PPEQ TOK_BEGIN
optModuleSpecificationBody
optModuleBody
TOK_END {
if($7) {
@ -423,9 +439,9 @@ ObjectIdentifierElement:
/*
* Optional module flags.
*/
optModuleSpecificationFlags:
optModuleDefinitionFlags:
{ $$ = MSF_NOFLAGS; }
| ModuleSpecificationFlags {
| ModuleDefinitionFlags {
$$ = $1;
}
;
@ -433,11 +449,11 @@ optModuleSpecificationFlags:
/*
* Module flags.
*/
ModuleSpecificationFlags:
ModuleSpecificationFlag {
ModuleDefinitionFlags:
ModuleDefinitionFlag {
$$ = $1;
}
| ModuleSpecificationFlags ModuleSpecificationFlag {
| ModuleDefinitionFlags ModuleDefinitionFlag {
$$ = $1 | $2;
}
;
@ -445,7 +461,7 @@ ModuleSpecificationFlags:
/*
* Single module flag.
*/
ModuleSpecificationFlag:
ModuleDefinitionFlag:
TOK_EXPLICIT TOK_TAGS {
$$ = MSF_EXPLICIT_TAGS;
}
@ -479,9 +495,9 @@ ModuleSpecificationFlag:
/*
* Optional module body.
*/
optModuleSpecificationBody:
optModuleBody:
{ $$ = 0; }
| ModuleSpecificationBody {
| ModuleBody {
$$ = $1;
}
;
@ -489,56 +505,36 @@ optModuleSpecificationBody:
/*
* ASN.1 Module body.
*/
ModuleSpecificationBody:
ModuleSpecificationElement {
$$ = $1;
}
| ModuleSpecificationBody ModuleSpecificationElement {
$$ = $1;
/* Behave well when one of them is skipped. */
if(!($1)) {
if($2) $$ = $2;
break;
}
#ifdef MY_IMPORT
#error MY_IMPORT DEFINED ELSEWHERE!
#endif
#define MY_IMPORT(foo,field) do { \
while(TQ_FIRST(&($2->foo))) { \
TQ_ADD(&($$->foo), \
TQ_REMOVE(&($2->foo), field), \
field); \
} \
assert(TQ_FIRST(&($2->foo)) == 0); \
} while(0)
MY_IMPORT(imports, xp_next);
MY_IMPORT(exports, xp_next);
MY_IMPORT(members, next);
#undef MY_IMPORT
ModuleBody:
optExports optImports AssignmentList {
$$ = asn1p_module_new();
AL_IMPORT($$, exports, $1, xp_next);
AL_IMPORT($$, imports, $2, xp_next);
AL_IMPORT($$, members, $3, next);
}
;
AssignmentList:
Assignment {
$$ = $1;
}
| AssignmentList Assignment {
if($1) {
$$ = $1;
} else {
$$ = $2;
break;
}
AL_IMPORT($$, members, $2, next);
}
;
/*
* One of the elements of ASN.1 module specification.
*/
ModuleSpecificationElement:
ImportsDefinition {
$$ = $1;
}
| ExportsDefinition {
$$ = asn1p_module_new();
checkmem($$);
if($1) {
TQ_ADD(&($$->exports), $1, xp_next);
} else {
/* "EXPORTS ALL;" ? */
}
}
| DataTypeReference {
Assignment:
DataTypeReference {
$$ = asn1p_module_new();
checkmem($$);
assert($1->expr_type != A1TC_INVALID);
@ -591,6 +587,10 @@ ModuleSpecificationElement:
* IMPORTS Type1, value FROM Module { iso standard(0) } ;
* === EOF ===
*/
optImports:
{ $$ = 0; }
| ImportsDefinition;
ImportsDefinition:
TOK_IMPORTS ImportsBundleSet ';' {
if(!saved_aid && 0)
@ -668,6 +668,20 @@ ImportsElement:
}
;
optExports:
{ $$ = 0; }
| ExportsDefinition {
$$ = asn1p_module_new();
checkmem($$);
if($1) {
TQ_ADD(&($$->exports), $1, xp_next);
} else {
/* "EXPORTS ALL;" */
}
}
;
ExportsDefinition:
TOK_EXPORTS ExportsBody ';' {
$$ = $2;

View File

@ -19,4 +19,6 @@ BEGIN
IMPORTS TypeB FROM ModuleB
TypeC FROM ModuleC ;
Z ::= INTEGER -- Can't specify only EXPORTS & IMPOTS
END

View File

@ -3,4 +3,6 @@ ModuleSetChoiceExtensibility { iso org(3) dod(6) internet(1) private(4)
DEFINITIONS ::=
BEGIN
Z ::= INTEGER
END