Solved

Writing a code generator

Posted on 2001-08-06
10
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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!

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

730 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