From ee40ee789c5e4d8bd92cc8baa28484480aafd44f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 27 Jul 2014 23:26:01 -0500 Subject: [PATCH] dbStatic: Allow empty recordtype bodies in DBD files A record type with an empty body is a declaration. The IOC will accept one of these in a DBD file as long as it has already loaded the full record type definition. This will allow device support to provide a DBD file that declares each record type it uses before giving the related device() entry. Later commits will explain why. --- src/ioc/dbStatic/dbLexRoutines.c | 18 ++++++++++++++++++ src/ioc/dbStatic/dbYacc.y | 11 ++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/ioc/dbStatic/dbLexRoutines.c b/src/ioc/dbStatic/dbLexRoutines.c index cf2406556..d1b3dc67e 100644 --- a/src/ioc/dbStatic/dbLexRoutines.c +++ b/src/ioc/dbStatic/dbLexRoutines.c @@ -62,6 +62,7 @@ static void dbMenuChoice(char *name,char *value); static void dbMenuBody(void); static void dbRecordtypeHead(char *name); +static void dbRecordtypeEmpty(void); static void dbRecordtypeBody(void); static void dbRecordtypeFieldHead(char *name,char *type); static void dbRecordtypeFieldItem(char *name,char *value); @@ -607,6 +608,23 @@ static void dbRecordtypeCdef(char *text) { return; } +static void dbRecordtypeEmpty(void) +{ + tempListNode *ptempListNode; + dbRecordType *pdbRecordType; + + if (duplicate) { + duplicate = FALSE; + return; + } + + ptempListNode = (tempListNode *)ellFirst(&tempList); + pdbRecordType = ptempListNode->item; + epicsPrintf("Declaration of recordtype(%s) preceeded full definition.\n", + pdbRecordType->name); + yyerrorAbort(NULL); +} + static void dbRecordtypeBody(void) { dbRecordType *pdbRecordType; diff --git a/src/ioc/dbStatic/dbYacc.y b/src/ioc/dbStatic/dbYacc.y index b8cc9b4cf..858e666d3 100644 --- a/src/ioc/dbStatic/dbYacc.y +++ b/src/ioc/dbStatic/dbYacc.y @@ -100,7 +100,12 @@ recordtype_head: '(' tokenSTRING ')' dbRecordtypeHead($2); dbmfFree($2); }; -recordtype_body: '{' recordtype_field_list '}' +recordtype_body: '{' '}' +{ + if(dbStaticDebug>2) printf("empty recordtype_body\n"); + dbRecordtypeEmpty(); +} + | '{' recordtype_field_list '}' { if(dbStaticDebug>2) printf("recordtype_body\n"); dbRecordtypeBody(); @@ -215,14 +220,14 @@ record_head: '(' tokenSTRING ',' tokenSTRING ')' dbRecordHead($2,$4,0); dbmfFree($2); dbmfFree($4); }; -record_body: /*Null*/ +record_body: /* empty */ { if(dbStaticDebug>2) printf("null record_body\n"); dbRecordBody(); } | '{' '}' { - if(dbStaticDebug>2) printf("record_body - no fields\n"); + if(dbStaticDebug>2) printf("empty record_body\n"); dbRecordBody(); } | '{' record_field_list '}'