EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: lexical analyzer for .db?
From: Andrew Johnson <[email protected]>
To: Heinrich du Toit <[email protected]>
Cc: TechTalk EPICS <[email protected]>
Date: Thu, 01 Nov 2007 10:10:36 -0500
Heinrich du Toit wrote:

Is there 'n lexical analyzer for .db files?


I guess there must be something in epics BASE somewhere?
But is it written in something like flex that can easily be
extended/used or is it some custom code nightmare?

The IOC's parser is written in flex and antelope (BSD-licensed versions of lex and yacc), the code for which you can find in base/src/dbStatic. Note that you need to parse a DBD file (to define the record types, fields, menu selections etc.) before you can completely understand a DB file.


However rather than directly grabbing and trying to use our lex and yacc files I would strongly recommend that you make use of the dbStaticLib library API which permits you to load, manipulate and save DBD and DB files; if you stick with the dbStatic API (documented in Chapter 14 of the EPICS IOC Application Developer's Guide) you're more protected against future changes to the syntax of the DB and DBD files.

O let me explain.
I want to make some sort of .db file pre-processor that can do some
modifications. Mainly macro expansion type stuff.
And this I want to use so that some rule stuff can be written in Macro's
and not in long complex records and hopefully make it easier to maintain
and understand and change. And then maybe also handle some other stuff
with the pre-processor to keep thing consistently linked ect... making
it more reliable and less prone to human error. Plus the person working
with it might not fully understand all the internal stuff of 'n db.

I'm going to assume that you're aware of the dbLoadTemplate() facilties of the IOC, and I'd be interested to hear what you need beyond what that already provides. I want to try and stop you from reinventing the wheel unnecessarily, but I'm not saying that what we have is comprehensive.


You should also be aware of the EPICS Extension MSI (Macro Substitution and Include) which implements dbLoadTemplate() expansion on a host machine and may speed up IOC boot time if you have lots of templates and macros to instantiate.

If you haven't already done so, have a look at the template facilities provided by VDCT. Their use may not be completely obvious (and you should ignore the "grouping" features which are not useful) but they provide the ability to create template hierarchies and instantiate them. VDCT really is the best way to design complex databases at least for anyone from an electronics background who is used to schematic diagrams.

In the language of the VDCT template expansion stuff, "macros" pass instance information from a parent to a child template, while "ports" pass information from a child to its parent; the "information" I'm talking about here are macro strings and are not directly related to database links although they will often be expanded in them.

It is also relatively easy to write a DB file parser in modern scripting languages such as Perl and Python, but it is also easy to omit some obscure pieces of the syntax. You should be aware that future major releases of Base will probably replace the 'C' dbStatic library with tools written in Perl (which will have a similar Perl library for manipulating the underlying data).

HTH,

- Andrew
--
When a distinguished but elderly scientist states that something is
possible, he is almost certainly right.  When he states that something
is impossible, he is very probably wrong.  -- Arthur C. Clarke

Replies:
Re: lexical analyzer for .db? Noboru Yamamoto
Re: lexical analyzer for .db? Heinrich du Toit
Re: lexical analyzer for .db? Emmanuel Mayssat
References:
lexical analyzer for .db? Heinrich du Toit

Navigate by Date:
Prev: webca compile on win32 鲍春雷
Next: RE: question about iocConsole Allison, Stephanie
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: lexical analyzer for .db? Benjamin Franksen
Next: Re: lexical analyzer for .db? Noboru Yamamoto
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·