Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 19th, 2006, 5:06 PM   #1
proudnerd
Newbie
 
Join Date: May 2006
Posts: 21
Rep Power: 0 proudnerd is on a distinguished road
Create an Interpreter

I'm sorry if this is the wrong forum, but I wanted to know how much programming experience it would take to make an interpreter for a new programming language. I'm new to programming, so there's a very small chance that I'll be making one any time soon, but I just wanted to know how much work is involved because I'm planning on creating a new programming language in the future.
proudnerd is offline   Reply With Quote
Old May 19th, 2006, 5:11 PM   #2
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
A lot of work is involved. Just stop thinking about interpreters right now. Chances are you won't understand what information is given to you about an interpreter if you've just started programming recently.
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old May 19th, 2006, 6:11 PM   #3
Edgar
Programmer
 
Edgar's Avatar
 
Join Date: May 2006
Location: Bathroom
Posts: 43
Rep Power: 0 Edgar is on a distinguished road
First get focus on assemly language and revers engineer, that will be your first step.
Here is a great book about that just click on the link below and serch for assemby languge. like jayme said forget about new languages and interpreters for now.
Edgar is offline   Reply With Quote
Old May 19th, 2006, 6:55 PM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 893
Rep Power: 4 The Dark is on a distinguished road
Making an interpreter is an excellent excercise in learning to program, it gives you a better insight into what the compiler you are using is doing in the background.
It can be a large project, but like any programming project, it can be broken down into smaller parts and tackled in pieces. e.g. write a scanner first to read the input into tokens, then write the parser to take the tokens and work out what to do with them.
You don't need to know assembler to write an interpreter, as the interpreter's output will end up being calls to functions in your program that perform some actions, rather than machine code.
The Dark is offline   Reply With Quote
Old May 19th, 2006, 10:04 PM   #5
msk420
Programmer
 
msk420's Avatar
 
Join Date: May 2006
Posts: 85
Rep Power: 3 msk420 is on a distinguished road
Ok the first step to creating a interperator would be to completely learn a language to the fullest extent that you can manage. Then when you are good in that language start thinking about your interperator... Don't start right off by trying to make a interperator your thinking way into the future.
__________________
Code Forums
msk420 is offline   Reply With Quote
Old May 20th, 2006, 12:09 AM   #6
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
It will take years of programming skill and experience to really develop a "WELL-DESIGNED" interpreter.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old May 20th, 2006, 12:25 AM   #7
msk420
Programmer
 
msk420's Avatar
 
Join Date: May 2006
Posts: 85
Rep Power: 3 msk420 is on a distinguished road
Yes it will. I suggest learning a language to the best extent that you can first.
__________________
Code Forums
msk420 is offline   Reply With Quote
Old May 20th, 2006, 3:59 AM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Scheme-like interpreters are fairly simple to make.
Arevos is offline   Reply With Quote
Old May 20th, 2006, 4:00 AM   #9
msk420
Programmer
 
msk420's Avatar
 
Join Date: May 2006
Posts: 85
Rep Power: 3 msk420 is on a distinguished road
It is still an interpreter and that requires some sort of knowledge of the language, I would say a fairly good amount of knowledge to do it.
__________________
Code Forums
msk420 is offline   Reply With Quote
Old May 20th, 2006, 8:11 AM   #10
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,193
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by proudnerd
I'm sorry if this is the wrong forum, but I wanted to know how much programming experience it would take to make an interpreter for a new programming language. I'm new to programming, so there's a very small chance that I'll be making one any time soon, but I just wanted to know how much work is involved because I'm planning on creating a new programming language in the future.
As others have said, it can be a very involved task. However, it really depends on what you had in mind for it, particularly with respect to how complex it needs to be.

If you actually want a bona-fide programming language, especially one with syntax/error checking of any kind, it can be a huge task. It's much more manageable if you instead are thinking of a simple script language with limited keywords and operands. By sticking to only a few very strict operation/operand formats, you could reduce the complexity immensely.

It would then be relatively trivial to 'compile' the code to a form of bytecode, but of course you'd need to invent this bytecode. It could be a very simple format with each instruction being a fixed size, with a few components such as operation, first operand, and second operand. Obviously, some of these fields would be unused for certain instructions, but could be left blank to keep the format consistent, unless space was at an extreme premium.

You could have direct bytecode equivalents for all basic instructions (like arithmetic and moving from one variable to another), while more complex commands (displaying a messagebox with text, for example) would be handled by passing parameters to a function built into your interpreter. As I see it, the hardest thing in this system would be handling memory allocation for (usually) dynamically-sized objects like strings, but even this could be worked around (allocating the memory during the 'compile to bytecode' stage, and not the 'interpret bytecode' stage).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is online now   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:19 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC