Commit 866bd7f7 authored by Lev Walkin's avatar Lev Walkin

*** empty log message ***

parent f9492a93
...@@ -51,14 +51,14 @@ typedef struct asn1p_module_s { ...@@ -51,14 +51,14 @@ typedef struct asn1p_module_s {
asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */ asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */
/* /*
* List of everything that this module IMPORTS. * List of everything that this module EXPORTS.
*/ */
TQ_HEAD(struct asn1p_xports_s) imports; TQ_HEAD(struct asn1p_xports_s) exports;
/* /*
* List of everything that this module EXPORTS. * List of everything that this module IMPORTS.
*/ */
TQ_HEAD(struct asn1p_xports_s) exports; TQ_HEAD(struct asn1p_xports_s) imports;
/* /*
* List of everything that this module defines itself. * List of everything that this module defines itself.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
#ifndef YYSTYPE #ifndef YYSTYPE
#line 72 "asn1p_y.y" #line 85 "asn1p_y.y"
typedef union { typedef union {
asn1p_t *a_grammar; asn1p_t *a_grammar;
asn1p_module_flags_e a_module_flags; asn1p_module_flags_e a_module_flags;
......
...@@ -61,6 +61,19 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr); ...@@ -61,6 +61,19 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
} \ } \
} while(0) } 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); ...@@ -223,13 +236,16 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
* Types defined herein. * Types defined herein.
*/ */
%type <a_grammar> ModuleList %type <a_grammar> ModuleList
%type <a_module> ModuleSpecification %type <a_module> ModuleDefinition
%type <a_module> ModuleSpecificationBody %type <a_module> ModuleBody
%type <a_module> ModuleSpecificationElement %type <a_module> AssignmentList
%type <a_module> optModuleSpecificationBody /* Optional */ %type <a_module> Assignment
%type <a_module_flags> optModuleSpecificationFlags %type <a_module> optModuleBody /* Optional */
%type <a_module_flags> ModuleSpecificationFlags /* Set of FL */ %type <a_module_flags> optModuleDefinitionFlags
%type <a_module_flags> ModuleSpecificationFlag /* Single FL */ %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> ImportsDefinition
%type <a_module> ImportsBundleSet %type <a_module> ImportsBundleSet
%type <a_xports> ImportsBundle %type <a_xports> ImportsBundle
...@@ -330,12 +346,12 @@ ParsedGrammar: ...@@ -330,12 +346,12 @@ ParsedGrammar:
; ;
ModuleList: ModuleList:
ModuleSpecification { ModuleDefinition {
$$ = asn1p_new(); $$ = asn1p_new();
checkmem($$); checkmem($$);
TQ_ADD(&($$->modules), $1, mod_next); TQ_ADD(&($$->modules), $1, mod_next);
} }
| ModuleList ModuleSpecification { | ModuleList ModuleDefinition {
$$ = $1; $$ = $1;
TQ_ADD(&($$->modules), $2, mod_next); TQ_ADD(&($$->modules), $2, mod_next);
} }
...@@ -351,11 +367,11 @@ ModuleList: ...@@ -351,11 +367,11 @@ ModuleList:
* === EOF === * === EOF ===
*/ */
ModuleSpecification: ModuleDefinition:
TypeRefName optObjectIdentifier TOK_DEFINITIONS TypeRefName optObjectIdentifier TOK_DEFINITIONS
optModuleSpecificationFlags optModuleDefinitionFlags
TOK_PPEQ TOK_BEGIN TOK_PPEQ TOK_BEGIN
optModuleSpecificationBody optModuleBody
TOK_END { TOK_END {
if($7) { if($7) {
...@@ -423,9 +439,9 @@ ObjectIdentifierElement: ...@@ -423,9 +439,9 @@ ObjectIdentifierElement:
/* /*
* Optional module flags. * Optional module flags.
*/ */
optModuleSpecificationFlags: optModuleDefinitionFlags:
{ $$ = MSF_NOFLAGS; } { $$ = MSF_NOFLAGS; }
| ModuleSpecificationFlags { | ModuleDefinitionFlags {
$$ = $1; $$ = $1;
} }
; ;
...@@ -433,11 +449,11 @@ optModuleSpecificationFlags: ...@@ -433,11 +449,11 @@ optModuleSpecificationFlags:
/* /*
* Module flags. * Module flags.
*/ */
ModuleSpecificationFlags: ModuleDefinitionFlags:
ModuleSpecificationFlag { ModuleDefinitionFlag {
$$ = $1; $$ = $1;
} }
| ModuleSpecificationFlags ModuleSpecificationFlag { | ModuleDefinitionFlags ModuleDefinitionFlag {
$$ = $1 | $2; $$ = $1 | $2;
} }
; ;
...@@ -445,7 +461,7 @@ ModuleSpecificationFlags: ...@@ -445,7 +461,7 @@ ModuleSpecificationFlags:
/* /*
* Single module flag. * Single module flag.
*/ */
ModuleSpecificationFlag: ModuleDefinitionFlag:
TOK_EXPLICIT TOK_TAGS { TOK_EXPLICIT TOK_TAGS {
$$ = MSF_EXPLICIT_TAGS; $$ = MSF_EXPLICIT_TAGS;
} }
...@@ -479,9 +495,9 @@ ModuleSpecificationFlag: ...@@ -479,9 +495,9 @@ ModuleSpecificationFlag:
/* /*
* Optional module body. * Optional module body.
*/ */
optModuleSpecificationBody: optModuleBody:
{ $$ = 0; } { $$ = 0; }
| ModuleSpecificationBody { | ModuleBody {
$$ = $1; $$ = $1;
} }
; ;
...@@ -489,56 +505,36 @@ optModuleSpecificationBody: ...@@ -489,56 +505,36 @@ optModuleSpecificationBody:
/* /*
* ASN.1 Module body. * ASN.1 Module body.
*/ */
ModuleSpecificationBody: ModuleBody:
ModuleSpecificationElement { optExports optImports AssignmentList {
$$ = $1; $$ = asn1p_module_new();
AL_IMPORT($$, exports, $1, xp_next);
AL_IMPORT($$, imports, $2, xp_next);
AL_IMPORT($$, members, $3, next);
} }
| ModuleSpecificationBody ModuleSpecificationElement { ;
$$ = $1;
/* Behave well when one of them is skipped. */ AssignmentList:
if(!($1)) { Assignment {
if($2) $$ = $2; $$ = $1;
}
| AssignmentList Assignment {
if($1) {
$$ = $1;
} else {
$$ = $2;
break; break;
} }
AL_IMPORT($$, members, $2, next);
#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
} }
; ;
/* /*
* One of the elements of ASN.1 module specification. * One of the elements of ASN.1 module specification.
*/ */
ModuleSpecificationElement: Assignment:
ImportsDefinition { DataTypeReference {
$$ = $1;
}
| ExportsDefinition {
$$ = asn1p_module_new();
checkmem($$);
if($1) {
TQ_ADD(&($$->exports), $1, xp_next);
} else {
/* "EXPORTS ALL;" ? */
}
}
| DataTypeReference {
$$ = asn1p_module_new(); $$ = asn1p_module_new();
checkmem($$); checkmem($$);
assert($1->expr_type != A1TC_INVALID); assert($1->expr_type != A1TC_INVALID);
...@@ -591,6 +587,10 @@ ModuleSpecificationElement: ...@@ -591,6 +587,10 @@ ModuleSpecificationElement:
* IMPORTS Type1, value FROM Module { iso standard(0) } ; * IMPORTS Type1, value FROM Module { iso standard(0) } ;
* === EOF === * === EOF ===
*/ */
optImports:
{ $$ = 0; }
| ImportsDefinition;
ImportsDefinition: ImportsDefinition:
TOK_IMPORTS ImportsBundleSet ';' { TOK_IMPORTS ImportsBundleSet ';' {
if(!saved_aid && 0) if(!saved_aid && 0)
...@@ -668,6 +668,20 @@ ImportsElement: ...@@ -668,6 +668,20 @@ ImportsElement:
} }
; ;
optExports:
{ $$ = 0; }
| ExportsDefinition {
$$ = asn1p_module_new();
checkmem($$);
if($1) {
TQ_ADD(&($$->exports), $1, xp_next);
} else {
/* "EXPORTS ALL;" */
}
}
;
ExportsDefinition: ExportsDefinition:
TOK_EXPORTS ExportsBody ';' { TOK_EXPORTS ExportsBody ';' {
$$ = $2; $$ = $2;
......
...@@ -19,4 +19,6 @@ BEGIN ...@@ -19,4 +19,6 @@ BEGIN
IMPORTS TypeB FROM ModuleB IMPORTS TypeB FROM ModuleB
TypeC FROM ModuleC ; TypeC FROM ModuleC ;
Z ::= INTEGER -- Can't specify only EXPORTS & IMPOTS
END END
...@@ -3,4 +3,6 @@ ModuleSetChoiceExtensibility { iso org(3) dod(6) internet(1) private(4) ...@@ -3,4 +3,6 @@ ModuleSetChoiceExtensibility { iso org(3) dod(6) internet(1) private(4)
DEFINITIONS ::= DEFINITIONS ::=
BEGIN BEGIN
Z ::= INTEGER
END 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