README.md
December 4, 2022 ยท View on GitHub
Description
Explains how to create a programming language..not a scripting language
More Info
| Submitted On | |
| By | telle |
| Level | Beginner |
| User Rating | 2.3 (21 globes from 9 users) |
| Compatibility | Delphi 5, Delphi 4, Pre Delphi 4 |
| Category | Miscellaneous |
| World | Delphi |
| Archive File |
Source Code
How To Create A Programming LanguageIn 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!