Code generation / markup language processing

Scott Bissett <sbisse01@harris.com>
11 Jan 1999 14:42:05 -0500

          From comp.compilers

Related articles
Code generation / markup language processing sbisse01@harris.com (Scott Bissett) (1999-01-11)
Re: Code generation / markup language processing nr@labrador.cs.virginia.edu (Norman Ramsey) (1999-01-15)
Re: Code generation / markup language processing Martin.Ward@SMLtd.Com (1999-01-20)
| List of all articles for this month |
From: Scott Bissett <sbisse01@harris.com>
Newsgroups: comp.compilers
Date: 11 Jan 1999 14:42:05 -0500
Organization: Harris GCSD
Keywords: question, code

First, let me preface this by saying that I have absolutely NO
experience in compiler construction, language construction,
etc. (other than an undergrad survey of prog. lang. class in which we
used lex and yacc for 2 small projects).


Having said that, I am looking for pointers/ideas/suggestions for a
(hopefully) small project I would like to undertake. I am using a
tool at work that was developed in-house to generate C-code.
Basically, we often need to control equipment with serial interfaces,
using an embedded processor. the embedded processor then acts as an
SNMPv1 agent for the device it talks to serially. Thus, using one
embedded processor, we can talk to an entire chain of devices, or
multiple chains of different devices, using only a MIB browser running
on Windows or Unix.


At present, the development process using our in-house tool is very
tedious. We first enter the serial communication protocol into a
database (I say database, only because it's in an MS Access .mdb file,
but it's only because the tool using DAO (data access objects) under
Visual C++). the database is really just a small handful of tables
containing bit/byte offset of particular data values, message
structure information for the particular device's communication
protocol, etc. The database is not very sophisticated. After we are
fairly confident the database is correct, we create an SNMP v.1 MIB
table. Each variable in the MIB is associated with an entry in a
record in one of the database tables.


Then we run the tool. It just reads the MIB, and reads the database,
and generates our C-code. the only problem is, the architecture of
the generated C-code is *compiled into the tool*!!! That means we
would have to recompile the tool to make small but significant changes
to the architecture of the generated code. Ugh!!


So, my quest is to build a better code generation tool. I suppose you
might say I'm in the requirements phase right now. I have a wish list
from the current state of the in-house tool that I would like to have
implemented. Some of the 'wishes':
1) must accept 'template' source code (doesn't have to be C. In fact,
the 'template' source should be language-independent).
2) must not modify any of the tool's source files (sure enough, the
current tool actually modifies the database during the code-generation).
3) will generate a MIB file based on the input database, instead of
having to manually generate a MIB. This is because there is a lot of
cohesion between database info and MIB info, and a change in the
database regresses into changing the MIB, and vice versa. If the
database were relational, it could handle this for me.
4) must be based on a command-line interface, such that it may be
pipelined. I really want it to be part of my makefiles, instead of
having to use a Windoze interface.
5) actually, I'd really just want it to be multi-platform, instead of
written to a specific OS. this is because right now, the code it
generates is for an OS other than Windows. Why require it to run on
Windows if the rest of the development is on something else?
...
There are quite a few other specifics I'd like, but I'm already running
long here. At any rate, I posted to comp.compilers for a reason. After
thinking about my requirements, I became apparent to me that what I
really need to do is define a 'markup language' for my tool. That way,
I can write 'generic' C-code using standard C plus my markups, process
the code using the tool (with added input from the database), and voila,
instant C-code (or like I said, ANY code).


As far as processing the database records, if it were just a flat-file
(or series of flat-files), I would think using awk is the most
straightforward. But what about pre-pre-processing my C-with-markups
files? Note that I don't need to actually parse the C-code, but I
just need to do text lookup and replacement for the markups in my
modified C-code. Any suggestions??


I'm sorry this is so long, but I'm new at this, and I'm still trying to
define how I'm going to attempt to solve this. If this type of problem
is outside the scope of this newsgroup, please accept my apologies.
Thank you in advance for any help you might provide,


Scott Bissett
Harris Electronic Systems GCSD
sbisse01 @ harris.com


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.