Computer Hope
Software => Computer programming => Topic started by: Linux711 on November 21, 2009, 09:32:01 PM
-
This is my idea for a programming language. I came up with it during a free period at school. It will be implemented as an interpreter in C++. I tried to design it so that it would be easy to program the interpreter. That's why it is made up of combinations of single characters. It is almost impossible to understand without reading what each character means. Please comment on it.
Vars:
* There are variables a-z and a stack
* Each of the a-z variables has 5 data types (total of 130 vars; 26 per array)
* The data types are string, bool, int, long, char
The data types are accessed this way:
VS - vars.string
VB - vars.bool
VI - vars.integer
VL - vars.long
VC - vars.character
The stack is accessed like this:
SS - stack.size (for all data types)
ST - stack.type
SA - stack.add (same as push in assembly)
SR - stack.remove (same as pop)
SO - stack.obtain (get without popping; only for top stack item)
Examples:
VSA"Hello World!" - puts the string 'Hello World!' into vars.string.a
---------------------------
SS10 - stack is size 10
STB - changes to bool
Commands/Reserved Words (Chars)
CO - command.output
CI - command.input
CS - command.screen (mainly used to clear screen)
CCT - command.compare.true?
CCF - command.compare.false?
CCG - command.compare.greater?
CCL - command.compare.less?
CCE - command.compare.end
Example:
VIA350 - the integer a is set to 350
VSA"A is equal to 350." - the string a is set to ...
CCTVIA,350 - integer a is compared with 350
COVSA - if true, the string a is output
CCE - end compare
Loops:
For like loop:
>#3 (code goes here) < - loops three times
>VII (code goes here) < - loops i times
While like loop:
>CCTVBX,1 (code here) <CCE - loops while the bool x is true (1=true,0=false)
>CCGVIX,VIY (code here) <CCE - loops while int x is greater than int y
It can also be done like this:
>CCGVIX,VIY
....
....
....
<CCE
If you are still reading this, thank you. It is not even close to done. I think I may need to add semicolons or something to separate commands in a single line loop.
So what do you think?
-
Well, I don't think that it is necessary for you to have long and complicated commands.
VSA"Hello World!" - puts the string 'Hello World!' into vars.string.a
It would pose a problem doing commands like this. There needs to be some kind of separator or something to identify the variable A and it's contents, "Hello World!". I think it would be best to stick to something like var.str.a = "Hello World!"
-
Well, I don't think that it is necessary for you to have long and complicated commands.
It would pose a problem doing commands like this. There needs to be some kind of separator or something to identify the variable A and it's contents, "Hello World!". I think it would be best to stick to something like var.str.a = "Hello World!"
um...there are only one character variables- so VS<character>"value" That's pretty easy to parse.
-
um...there are only one character variables- so VS<character>"value" That's pretty easy to parse.
Okay, so it wouldn't matter. But using commands like that is going to curse you with unmaintainable code. I don't like it.
-
I would think it's more a practice in string parsing and language theory then an attempt to make a feasible programming language ::)
-
Hey, go easy on him. He is learning as he goes.
Yes, he could make is a lot more simple. But why? If you learns from the process, let him do it.
Multiple stacks are seldom needed. But if you want them and it makes you feel good, do it!
As for parsing, you can parse almost anything.
Except plain English.
-
wouldnt it be easier just to use assembly? faster anyway...
-
wouldnt it be easier just to use assembly? faster anyway...
I would think it's more a practice in string parsing and language theory then an attempt to make a feasible programming language
-
thats weird, i was reading, i skipped yours and read the next one...
-
I would think it's more a practice in string parsing and language theory then an attempt to make a feasible programming language
You're right.
Yes, he could make is a lot more simple. But why? If you learns from the process, let him do it.
A lot more simple. How do you mean?
Do you mean easier to read? It's not meant to be easy to read, but easy to interpret.
Also, how do I make libraries in my programming language? If there are too many different ways to explain, then how do they do it in C?
Anyway, thanks for the replies.
-
for a library you could allow for different functions; for example, you could have a "CALL" instruction- for example:
VSA"string"
CALL UPCASE
the CALL'd functions could then work with variables in predefined locations, for example, in this case, perhaps UPCASE uppercases whatever is in VSA. Again- similar to assembly, since almost all Assembly interrupts access/modify registers to perform their task. This type of thing could easily be extended to basic functions as well, such as ADD, SUB, etc.
-
Creation of a library is not alwasy needed. I mean you do not have to make your own lirary manager. Just use one that is already available. You can build a libray in almost any system-level language. The idea is to reduce that size of the compiled EXE file by not including the kitchen sink.
Or, the alternative, is to have a run-time library. This is a masive hunk of code that is loaded at run time, the needed parts are lcopied into the work area memory. This is a pratical way to smake things simple.
For example, a specific program does not use the floading-point stuff. It is in the library, but it is not loading into the program memory because it is not neeed. But if another program needes it, it will be loaded for that program to use.
-
it's an interpreter, I don't think there are any plans to make a compiler for it. Therefore all the core stuff such as floating point and string parsing or whatever else they choose can be placed within the interpreter.
-
i think it is impassible to do this all alone you need someone else you need a lot of people to make commands to program to test and more it's impassible but don't give up it could happen if you have a lot of people to work with and i think it is impassible to do alone
-
by the way you need to write exe files too...
i can help you if you want ... :)
-
i think it is impassible to do this all alone you need someone else you need a lot of people to make commands to program to test and more it's impassible but don't give up it could happen if you have a lot of people to work with and i think it is impassible to do alone
No, it's actually quite "passible". it's a good little one-man project.
-
yeah i know, but what i mean is
if he/she want to do this you need to have more people else it's to much
-
Right here!
We will help the OP.
http://en.wikipedia.org/wiki/Tiny_C_Compiler
That is a start. You can see how somebody else did a very small C interpreter.
cats of course, he does not have to duplicate that effort. That would be pointless. But it should increase him to see how that that individual along with others developed a very small implementation of a language that is considered to be rather difficult.
In the original poster could call his new language almost anything he wants. There are no fast and hard rules about how you do something for your own entertainment. As long as it does not infringe on the rights of others.
Also, the language does not even have to be complete. It does not have to pass any academic standard. It does not have to be flawless. If it produces some result that pleases the creator, that is good. Whether or not other people would approve should not be the criteria. Now some point, he might want to publish his work. That would be another issue.
A simple interpreter with a built-in line editor can be made in about all I would say, maybe just under 3000 lines of code. I just don't remember. That was a long time ago when I did that.
-
yeah i know, but what i mean is
if he/she want to do this you need to have more people else it's to much
No. It isn't, actually. It might be overwhelming if they had no design; but they have already planned out a good bit of the project, and once you have a good design the programming behind it often comes a lot easier.
Oh, and I wrote a far more comprehensive and complicated Script language myself.. one person. It literally took a single night after good design much like the original posters, whereas many of my other whimsy project that I go into without any real plan take ages, and even then I usually end up scrapping it all and starting again with the design stage.
-
It literally took a single night after
good design much like the original posters
That's right on target!