article

How To Create A True Programming Language

Email
Submitted on: 1/1/2015 6:56:00 AM
By: telle (from psc cd)  
Level: Beginner
User Rating: By 9 Users
Compatibility: Delphi 5, Delphi 4, Pre Delphi 4
Views: 1808
 
     Explains how to create a programming language..not a scripting language

 
				How To Create A Programming Language

In this tutorial i will explain everything needed to make a true
programming language, not a scripting language, although i will
explain some on that, but there isnt much point...


Okay, i know many people who have always wanted to make a programming
language(mainly me...), but a lot could never figure out how to make
a true language, the truth is, its hard, very hard, not because you
have to make it in C++, because thats a lie, it can be created in
almost any language, mainly a language will the ability to replace
and do some other basic commands, a true language like c++ or delphi,
compiles it's code to assembly, a machine spacific chip, anyway,
the langauge is just a way to make things easier, assembly is not
the easiest thing to learn, it usally takes many,anywhere like,
10 to 100,000 programers, who mainly only know assembly, the truth is
you must convert a unique language syntax, to assembly, or, you could
simply convert it to a language that can already be compiled to asm,
example, say you made a language called SBL(Simple Basic Language),
and your basic hello world program looked like this:


SBL.Program: HelloWorld.SBL
SBL.Vars: Str
SBL.SetVar: Str,Hello World
SBL.Body: { SBL.OutPut(Str) }
SBL.EndProgram


alright, now say, you want to be lazy, and convert it to c++
and let it compile it, thats fine, doesnt make you anyless of
a programmer...you would have todo this


SBL Version:

SBL.Program: HelloWorld.SBL
SBL.Vars: Str
SBL.SetVar: Str,Hello World
SBL.Body: { SBL.OutPut(Str) }
SBL.EndProgram


C++ Version:

#include <iostream.h>

int main()
char Str;
Str = "Hello World";
{
cout << Str;
return;
}


Now...the hard part would be translating the SBL version to the C++ version
you would have to first, create a temp file like HelloWorld.Cpp
then translate it like this:
Line-By-Line:


SBL.Program: HelloWorld.SBL

{this simply tells you the file name, so you really dont need it, just delete the line,}

SBL.Vars: Str

{hum...ok...you can do 2 things here, create the c++ var like:
char Str;
or, you turn it into a string right then and there}


SBL.SetVar: Str,Hello World

{ok..if you applyed the first method, then you use this, else, you directly do it
Str = "Hello World";
please note: i dont know much c++ anymore, so dont be offended if its wrong, anyway
well, now you have 2 lines translated...
char Str;

Str = "Hello World";
ok...}

SBL.Body { SBL.OutPut(Str) }

{ok, by now you get my point, this is transformed to:

{
cout << Str;
Return 0;
}


or whatever function you use,

now you have one line left:}


SBL.EndProgram

{this basicly was Return 0;...but oh well}

{ok so by now youve made a file from HelloWorld.SBL to HelloWorld.Cpp
youve translated the code...but you havnt found all the required header files
...so you basicly scan all the functions used and compare it to a reference,
(which just tells which function belongs to which header file)... well, now
you have the translated segments, the header segments, and a file called HelloWorld.Cpp}

...now what? well first you combine the segments, then save the resulting code to
HelloWorld.Cpp, then compile the file to a .OBJ...then you link it to an EXE...
then you can now delete HelloWorld.Cpp, HelloWorld.Obj, which leaves you with
HelloWorld.SBL and HelloWorld.EXE...and there you have it, an explaination on
how to create a true programming language...now for scripting languages...
you see them all over psc, vb world, delphi world, c++ world, well they are
by far a lot easier to make, like youll see, its just an interpreter slapped with source code
to interpret...thats your job, im not explaining it...this is my 12 minute tutorial. thank you
for reading it and please vote and leave comments!



Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.