[esnacc-dev] [PATCH 4/5] compiler/core/y.tab.y: Enable AUTOMATIC TAGS
Aaron Conole
aconole at bytheb.org
Fri Jul 15 16:07:51 UTC 2016
This commit introduces automatic tagging as an experimentally supported
extension. Some basic interoperability testing has been done. A test
suite will be added in a future commit.
Signed-off-by: Aaron Conole <aconole at bytheb.org>
---
NEWS | 3 +++
compiler/core/print.c | 28 +++++++++++++---------------
compiler/core/y.tab.y | 31 +++++++++++++++++++------------
3 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/NEWS b/NEWS
index 876b952..5a56401 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@
* Fixed minbuf to follow the GenBuf abstraction
* Fixed GenBuf prototype
* Moved GenBuf macros to static inline functions
+* Added support for modern style CONTAINs/SIZEs
+* Fixed default value generation code for the C++ backend.
+* Added experimental AUTOMATIC tags support
=======================================================================
diff --git a/compiler/core/print.c b/compiler/core/print.c
index 4a745a5..60d3b22 100644
--- a/compiler/core/print.c
+++ b/compiler/core/print.c
@@ -94,29 +94,27 @@ PrintModule PARAMS ((f, mod),
Module *mod)
{
- if (mod->status == MOD_ERROR)
- {
- fprintf (f, "WARNING: this module contains errors\n");
- fprintf (f,"(probably some type/value is referenced but is not defined or imported)\n");
- fprintf (f,"The prog. may croak, cross your fingers!\n");
+ if (mod->status == MOD_ERROR) {
+ fprintf(f, "WARNING: this module contains errors\n");
+ fprintf(f,"(probably some type/value is referenced but is not defined or imported)\n");
+ fprintf(f,"The prog. may croak, cross your fingers!\n");
}
+ fprintf(f, "%s ",mod->modId->name);
+ PrintOid(f, mod->modId->oid);
- fprintf (f, "%s ",mod->modId->name);
- PrintOid (f, mod->modId->oid);
-
- fprintf (f, "\nDEFINITIONS ");
+ fprintf(f, "\nDEFINITIONS ");
if (mod->tagDefault == EXPLICIT_TAGS)
- fprintf (f, "EXPLICIT TAGS");
-
+ fprintf(f, "EXPLICIT TAGS");
else if (mod->tagDefault == IMPLICIT_TAGS)
- fprintf (f, "IMPLICIT TAGS");
+ fprintf(f, "IMPLICIT TAGS");
+ else if (mod->tagDefault == AUTOMATIC_TAGS)
+ fprintf(f, "AUTOMATIC TAGS");
else
- fprintf (f, "\n\n -- compiler error unknown tag default");
-
+ fprintf(f, "\n\n -- compiler error unknown tag default");
- fprintf (f, " ::=\nBEGIN\n\n");
+ fprintf(f, " ::=\nBEGIN\n\n");
diff --git a/compiler/core/y.tab.y b/compiler/core/y.tab.y
index dfc48c0..26fce55 100644
--- a/compiler/core/y.tab.y
+++ b/compiler/core/y.tab.y
@@ -517,10 +517,8 @@ TagDefault:
| IMPLICIT_SYM TAGS_SYM { $$ = IMPLICIT_TAGS; }
| AUTOMATIC_SYM TAGS_SYM
{
- printf("Automatic Tags are not properly supported.\n");
- printf("%s(%ld). Using Explicit tags.\n", modulePtrG->asn1SrcFileName,
- myLineNoG);
- $$ = EXPLICIT_TAGS;
+ $$ = AUTOMATIC_TAGS;
+ fprintf(errFileG, "WARNING: AUTOMATIC tags are still experimental.\n");
}
| empty
{
@@ -1093,14 +1091,16 @@ SequenceType:
SetupType (&$$, BASICTYPE_SEQUENCE, $1);
- if (AsnListCount ((AsnList*)$2) != 0)
- {
+ if (AsnListCount ((AsnList*)$2) != 0) {
n = (NamedType*) FIRST_LIST_ELMT ((AsnList*)$2);
n->type->lineNo = $1;
}
$$->basicType->a.sequence = $2;
+ if (modulePtrG->tagDefault == AUTOMATIC_TAGS) {
+ AutomaticTagNamed($$->basicType->a.sequence);
+ }
}
| SequenceOpening RIGHTBRACE_SYM
{
@@ -1318,12 +1318,16 @@ SetType:
SetupType (&$$, BASICTYPE_SET, $1);
/* reset first elmt's line number */
- if (AsnListCount ((AsnList*)$2) != 0)
- {
+ if (AsnListCount ((AsnList*)$2) != 0) {
n = (NamedType*)FIRST_LIST_ELMT ((AsnList*)$2);
n->type->lineNo = $1;
}
+
$$->basicType->a.set = $2;
+
+ if (modulePtrG->tagDefault == AUTOMATIC_TAGS) {
+ AutomaticTagNamed($$->basicType->a.set);
+ }
}
| SetOpening RIGHTBRACE_SYM
{
@@ -1361,13 +1365,16 @@ ChoiceType:
SetupType (&$$, BASICTYPE_CHOICE, $2);
- $$->basicType->a.choice = $4;
-
- if (AsnListCount ($4) != 0)
- {
+ if (AsnListCount ($4) != 0) {
n = (NamedType*)FIRST_LIST_ELMT ($4);
n->type->lineNo = $2;
}
+
+ $$->basicType->a.choice = $4;
+
+ if (modulePtrG->tagDefault == AUTOMATIC_TAGS) {
+ AutomaticTagNamed($$->basicType->a.choice);
+ }
}
;
--
2.5.5
More information about the dev
mailing list