Solved

Writing a code generator

Posted on 2001-08-06
10
267 Views
Last Modified: 2010-04-15
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
Comment
Question by:arut
10 Comments
 
LVL 2

Expert Comment

by:obg
Comment Utility
Please specify what you want to do. I don't think there is a generic code generator out there...
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
Comment Utility
>>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
 
LVL 86

Expert Comment

by:jkr
Comment Utility
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
 

Expert Comment

by:gaurangbhatt
Comment Utility
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
 
LVL 2

Accepted Solution

by:
obg earned 100 total points
Comment Utility
Why not yacc? (It's a code generator for parsing text and semantics) Search for it on the net.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Expert Comment

by:digized
Comment Utility
PERL, baby!
0
 

Author Comment

by:arut
Comment Utility
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
 

Assisted Solution

by:prabhuram
prabhuram earned 100 total points
Comment Utility
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
 
LVL 1

Expert Comment

by:nhuanvn
Comment Utility
Yeah, LEX + YACC is good to start with. I recommend
BISON [A variant of LEX + YACC] which has both
Windows and Unix versions.
0
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now