Solved

Writing a code generator

Posted on 2001-08-06
10
286 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
ID: 6355438
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
ID: 6355565
>>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
ID: 6355595
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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Expert Comment

by:gaurangbhatt
ID: 6359263
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
ID: 6359745
Why not yacc? (It's a code generator for parsing text and semantics) Search for it on the net.
0
 

Expert Comment

by:digized
ID: 6365185
PERL, baby!
0
 

Author Comment

by:arut
ID: 6371288
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
ID: 6396597
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
ID: 6485298
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
ID: 9412382
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

776 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