Data Dictionary and Code Generator 
Author Message
 Data Dictionary and Code Generator

Well, I'm revisiting the whole 'code generation' issue again. I like
C, I do... but some aspects of it could be enhanced.

I've made a tool which lets me write 'c-like pseudocode', and spits
out C source and header files. It does several handy things, including

1. Converts Python-like indenting to curly braces.

2. Generates the header files based off of the source you supply.

3. Contains a data dictionary, that allows you to specify a variables
type once, and from then on, whenever it encounters that variable in a
declaration or as a parameter, automatically supplies its type.

Number three is the most useful. Whenever I say 'i' or 'j', I meant
'int'... whenever I say 'go', I mean 'struct GAMEOBJECT_T *'. Why
should I have to declare it every time? As long as I'm rigidly
consistent in variable use, which I am, using a data dictionary takes
a lot of the pain and bother away.

Here's some sample pseudocode, and its resulting output.

DECLARE i, j            ==>
int i;
int j;

public int main(void)   ==>
extern int main(void)

private int square(x)   ==>
static int square(int x)

It was an interesting exercise. The most important part of it is the
data dictionary. The other features are nice, but the data dictionary
is the feature I would most like to have integrated into my
development environment (currently MSVC).

Has anyone heard of a formal tool which automates type declaration in
this manner? It's not that I mind declaring it, I just mind declaring
it EVERY SINGLE TIME I use it. :-|




Sat, 10 Dec 2005 05:59:14 GMT  
 Data Dictionary and Code Generator

Quote:

> 1. Converts Python-like indenting to curly braces.

If it floats your boat...

Quote:
> 2. Generates the header files based off of the source you supply.

This could be useful. I guess it parses static/extern for
functions and objects, and only includes declarations of ones
with external linkage, and auto-generates include guards, etc.

Quote:
> 3. Contains a data dictionary, that allows you to specify a
> variable's type once, and from then on, whenever it encounters
> that variable in a declaration or as a parameter, automatically
> supplies its type.

> Number three is the most useful. Whenever I say 'i' or 'j', I
> meant 'int'...

Whereas I'm as likely as not to mean size_t!

Quote:
> whenever I say 'go', I mean 'struct GAMEOBJECT_T *'. Why
> should I have to declare it every time? As long as I'm
> rigidly consistent in variable use, which I am, using a
> data dictionary takes a lot of the pain and bother away.

Loop iterators are reinitialised at the start of each
for statement. Why not just make them global variables? :)

--
Simon.



Sat, 10 Dec 2005 09:48:51 GMT  
 Data Dictionary and Code Generator

Quote:

> This could be useful. I guess it parses static/extern for
> functions and objects, and only includes declarations of ones
> with external linkage, and auto-generates include guards, etc.

yeah.

Quote:
> Loop iterators are reinitialised at the start of each
> for statement. Why not just make them global variables? :)

ha! I experimented with that once, with disastrous results, and
learned to stay away from that. I was using a shared buffer instead,
but this loop iterator is an example of why it didn't work. Let's say
function 1 executes function 2 in a loop, incrementing i every time.
and function 2 calls function X in a loop, incrementing i every time.
bam! bzzt! that's all she wrote.

--Kamilche



Sat, 10 Dec 2005 15:29:45 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Data dictionary (symbol xref) generator, results

2. FREE CODE!: Dictionary template (works like VBS Dictionary)

3. FREE CODE!: Dictionary template (works like VBS Dictionary)

4. dictionary routines and/or dictionary wanted.

5. Data dictionary+DFD

6. Data Dictionary

7. Data dictionaries

8. looking for a data dictionary

9. Accessing Dictionary Data type exposed in COM object

10. searching for dictionary database/code

11. Test Data Generator - FREE Demo

12. Test Data Generator - FREE Demo

 

 
Powered by phpBB® Forum Software