HyperNews Home
Using HyperNews (Instructions)

 Next-in-Thread Next-in-Thread
 Next Message Next Message

Feedback It not easy 

Forum: Visual Languages List
Re: Question How do you create a programming language?
Date: 2002, Feb 22
From: <Anonymous>

1. You will have to make a string parser, you will have to make a function to extract quoted text and also take into account escape sequences the replace it with an variable id number like $STRXXX.
2. After you extract and replace then you will have to have some sort of hashing and mapping class that will allow you to look up your variables while the script runs.
3. After this you will have to load up some sort have hash and map of all the operators and operands there are and there precedence.
4. The read line at a time.
5. After you do that you will need to make a generic discriminator(kind of hard) that will allow you to generally determine if the character you are looking at in the char arrayed line of code is a operator or an operand.
6. No go back through your parsed code, sin(2+2)*3 changes into (string array)”sin”,”(“,”2”,”+”,”2”,”)”,”*”,”3”
7. Remember if you find a subtraction sign after you find a operator “+”,”-“ then /*treat it as variable and */insert a “-1”,”<*>” into the array, it has to replace the negative sign, the “<*>” has to have the highest precedence of all no matter what and has to treated more are less like a multiplication sign
8. You will have to do the same thing before certain operators like the parentheses
9. You will now need to make so sort of infix to postfix converter, not that may sound hard, it is sort of. But this is where your function map to precedents comes in handy. [I recommend Applications Programming in ANSI C 3rd Edition]
10. After the code has been arrange into postfix(remember commas have the lowest precedence or near to it) go back over it and remove the commas or not if you will have functions with same name but different parameter lengths.
11. Have a function that finds what parts of the post-code can be executed [2+a*3= a 3 * + 2] first as you can see, I find the multiplication sign first go back two spaces in the array sense it has a lookup value for two parameters so.
12. ASM LIKE STUFF
13. AX= a 3 *
14. BX= AX 2 +
15. Now remember just go line by line. Compile a little bit at a time. After all that is done spit it out into a file and you will have a have fubar assembly file which then could be further compiled if you had access to some operations systems assembly bit code or what every or the bit codes for a processor
16. For logic things like if else and looping you will have to do that at a different level.
17. You will have a assembly line reader function
18. Then determine if it has a logic or looping switch
19. If it meets the case then continue on (say if(true)) else if(false) then you will have to start count ifs and elses in nested ifs statements if you want them. For looping statements all you have to is…
20. First if the statement is true while(true) then just go to the next line and keep executing
21. If it is false then you will have to find the (VB)wend of the while the continue after that.
22. If the statement was true then you hit the corresponding (VB)wend then you will have to go up through the asm code and find the first line of asm the was the entry point for the looping statement
23. AX= A 100 <
24. AX While or it may end up as While AX
25. Any way the entry point of the while loop is the AX= A 100 <
26. I still have trouble with my (VB) mock up language
27. Mostly with the assignment operators

 Next-in-Thread Next-in-Thread
 Next Message Next Message

 Add Add
to: "It not easy"

 Members Members
 Subscribe Subscribe
 Admin Mode Admin Mode
 Show Frames Show Frames
 Help Help


Forum Catagories:
Entertainment and Recreation
  • Sports
  • Music

  • Humanities (Graphics, Images, Photography, Art, Philosophy and Literature)
    Science
    Computers and the WWW
  • Languages/Operating Systems (Java, HTML, Windows)
  • WWW

  • Government and Politics
    Business, Finance, and Economics
    Education
    Society and Culture

    Earn money with Scour!
    Google
     
    Web www.HyperNews.org
    Earn money with Scour!