Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 12th, 2003, 05:30 PM
neus neus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: MOV @R1, P1 ; RAM (40H) <= OCAH
Posts: 18 neus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Compiler/Interpreter resources

Does anyone has any kind of resources about creating compilers/interpreters ?
I just wanted to hv some exprience building this kind of software.
I don't pretend to build anything complex, just very simple stuff.

regards,
idss

Reply With Quote
  #2  
Old October 13th, 2003, 12:35 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Click here for more information.
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,717 Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 12 h 42 m 30 sec
Reputation Power: 1179
This is probably a good starting point:
http://www.oreilly.com/catalog/lex/
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month

Reply With Quote
  #3  
Old October 15th, 2003, 04:42 PM
dog135's Avatar
dog135 dog135 is offline
Doggie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Seattle, WA
Posts: 751 dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 38 m 25 sec
Reputation Power: 7
Have you learned about function pointers yet? I've written several (4+) interpreters using the following method:

Write up a list of all your commands. Keep them simple, and assembly-like. You'll want to figure out how you use variables here too.

Create a function for each of your commands, all the functions need to have the same interface. (I use "void functionName(void)")

Create an array of function pointers and point each element to each of your functions. This way, you're assigning a number to each function.

Accept an array of integers (or unsigned chars) as the program, loop through each value and call the appropriate function pointer. The location in the program should be kept track of by a single variable, (I use "pc") the function advances this variable as needed, or moves it in the case of a branch. If a function requires a variable, pull it's identifier from the program.

Example:
Commands:
assign v1 literal
add v1 v2 (v2 added to v1)

program written out:
assign 1 100 (variable #1 = 100)
assign 2 150 (variable #2 = 150)
add 1 2 (add var#2 to var#1, var#1 now = 250)

if the command "assign" is stored in cmds[0] and "add" is stored in cmds[1], then the above program would be stored as:
0,1,100,0,2,150,1,1,2 (this is your p-code)

After you get your program working well this way, then you write the language translator. This can be simple if your code is assembly like, or complex if you want to allow variable names, functions, and other stuff. (variable names would be stored internally, then converted to a number later) I've used a couple of my interpreters without writting this step. They were used for small, embedded programs. (code embedded inside the data)

At least, that's how I did it, I'm sure there's other ways. This does end up running REALLY fast though.
__________________
"Science is constructed of facts as a house is of stones. But a collection of facts is no more a science than a heap of stones is a house." - Henri Poincare

Last edited by dog135 : October 15th, 2003 at 04:46 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Compiler/Interpreter resources


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT