• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

Writing a code generator

I want to write a code generator to do some repetitive tasks...

I have heard of state machines and parsers being used to to this, but don't have a clear
picture of how to go about doing this...


Any help in this direction would be greatly appreciated.
Shell scripting also is o.k.


Thanks,
arut
0
arut
Asked:
arut
2 Solutions
 
obgCommented:
Please specify what you want to do. I don't think there is a generic code generator out there...
0
 
AlexVirochovskyCommented:
>>Any help in this direction would be greatly appreciated.

If you use C++, see STL (Standart Template Library).
For C I recomend you C Code Generator
http://www.ida.ing.tu-bs.de/academics/labs/sweng/beschreibung/tau_htmlhelp/ccode.html 
0
 
jkrCommented:
I've written some code generators, and the complexity of this task ranges from 'simple' to 'highly complex', depending on what to comply with - what is your goal?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
gaurangbhattCommented:
The best way to write a code generater is using scripts.
Using any other compiling languages would be like you are not making use of the language efficiently.

I prefer nawk but you can use perl as well. I have never used perl.

Hope this helps.
0
 
obgCommented:
Why not yacc? (It's a code generator for parsing text and semantics) Search for it on the net.
0
 
digizedCommented:
PERL, baby!
0
 
arutAuthor Commented:
Shell scripts is a good idea.Basically I want to start of writing a code generator based
on a state machine and parser to do some trivial repetitive kind of a task.

Maybe copying lines of text from one file to another( Couldn't think of a better example ).

Later on, once I get the hang of it I would like to do more complex stuff.


I need a working model to start with.


arut
0
 
prabhuramCommented:
you start with scanning the input, it can be easily done thru LEX (lexical anayser) and in the second phase you go for YACC (parser) which parses the tokens supplied and after that you have to construct the parse trees and validate them and you need to generate code at the end of validation. for the remaining part mentioned above, i suggest you to go for using C.
-prabhuram
<edited by YensidMod>
0
 
nhuanvnCommented:
Yeah, LEX + YACC is good to start with. I recommend
BISON [A variant of LEX + YACC] which has both
Windows and Unix versions.
0
 
sunnycoderCommented:
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with 120:80 split between obg  and prabhuram

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Sunny
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now