PDA

View Full Version : what's compiling ???



Lionheart008
27-10-2009, 00:06
dear all thinbasic and *basic users :) !

I have a simple question belongs to my new powerbasic project ("lionbasic_warp demo"). this one looks something like powerbasic gui, hehe, but I will do quite other things for the future with graphic inputs so I will try to mix freebasic/powerbasic/thinbasic possibilities. It was only a test for understanding powerbasic language. I have written this lionbasic warp demo last days, week. and I would say thanks to jose roca for general help too :)

now my "heavy" and "hard" question:

What is "compiling" ? I mean, I have a text editor, so like Thinair does it too. What for do you need for creation of compiling structures ? For every command and syntax a own DLL and command and function declaration ? so I have done with "lion_gfx" module for
thinbasic ? do you know more about such things ???

I know charles pegge "oxygen project" I admire. A lot of respect to this asm work!
I know delphi and c++ a few. I know java a few and lightwave, realsoft 3d and cinema 4d and of course blender 3d ;)

I am writing here because I have a dream some years before to make a real own 3d application calls "Inka 3d". I don't like c++. I have tried and visit a lot of course around it, but I don't like really windows appplications they are looking always to the same. so I have bought (I repeat BOUGHT!) powerbasic!!! I have tried to make up my mind to get a new LIONBASIC graphic language like TBGL of petr here and Micheal H. for 2D works to mix the best things from THINBASIC, POWERBASIC and FREEBASIC. I don't know how to do this one, I am truly, but I have to make it, because I have the power and enthusiasm for it :D So I am writing this silly things like "LionBasic". It's a simple GUI for showing what's possible with making a few code lines !

I will add this program here.

It must be possible to create new things like TBGL or GDIplus features for Thinbasic. I love (that the mainly part of I like!) thinbasic, I like Freebasic and I am curious about Powerbasic but the whole GUI looks very dry. Like dry wine ! I have own ideas to make a GRAPHIC COMPILER (that's what I am here for!) so I called it "LIONBASIC_Warp". the title belongs to enterprise and Star wars :D

I know what horrible work it is to make an own compiler or Editor. My mind changed excactly one years ago I have seen some Freebasic example how (simple!!!) to create new graphic inputs and demonstrations of games. I was very impressed! Thinbasic I love for it's clear and simple syntax. I have difficult around powerbasic (because new for me!) but very detailed designed and go to very deep of programming language (translated from c++) I liked a lot how to do new GUI's. I have build last week some of new GUI's with DLL and so I try to go a new way. I cannot specify my Lionbasic Warp program, but it should do some graphic and calculations input.

so I have this simple question to myself. I have build this editor "lionBasic Warp" and NOW??? How does a compiler work ? How I can make a own DLL to create a new Language, simple and with a clear overview ???

uargh :)

best regards, Frank Lionheart

best thanks to eros, petr for reflections and comments :)

zlatkoAB
27-10-2009, 00:37
Uh man you put here so many questions in one post.
I study this thematic but not in your direction.
I study FreeBasic to and can say that is excellent.
Not becose is free then becose is really powerfull and i think(just think)
that is little bit easy to undestand then PowerBasic(maby i'm wrong).
However i just lookin in one free GUI library:
http://www.beyondata.com/default.htm
But this is just for GUI.s and there be some others 3d look in :
http://www.geocities.com/SiliconValley/Vista/7184/guitool.html

OH you say compiling, compiling is translating one source code to
another( such a stupid explaination)- compiler is translator+parser
or something like that...

Good luck...

Lionheart008
27-10-2009, 00:57
hi zlatko :)

thanks for reply and good wishes. my short question: what was you dream to make a compiler like aurel basic ??? this one is basically, isn't it ? So I am at this similar point of view. I know freebasic, I wonder how it gets so many people there although it's no more updates ? it's a simply great language. therefore I have tried to include new functions to thinbasic with lionbasic_gfx module ;)

thanks in advance, frank

zlatkoAB
27-10-2009, 01:08
What was my dream?
I'm not quite sure - but i think maby some day if i have enough time
write simple basic compiler.
AurelBasic is not compiler he is very simple interpreter.
Why i made them - first i love programming and second I always
want my own basic like language(most for fun...)

Lionheart008
27-10-2009, 02:34
simple compiling example:

here a very simple c++ example I have built :)

do it: type in for example:

6+4-4*9

...

translate in asm...

best regards, the exe file I add.

frank

Michael Hartlef
27-10-2009, 13:26
Hi Franck,

As I have worked in past on my own compiler and still do once in a while, here are my 2 cents to the story. Warning: This is my personal view of things and I don’t claim to know everything about it:



dear all thinbasic and *basic users :) !

What is "compiling" ? I mean, I have a text editor, so like Thinair does it too. What for do you need for creation of compiling structures ?

What is compiling? In the context of programming languages it is in general a translation from one language into another one. Be it from C++ into assembler, from BASIC into Byte-Code, anything. Some compilers do just that, some create a full executable or DLL or other stuff from it.

Wikipedia is not always correct, but I think this link describes it well:

http://en.wikipedia.org/wiki/Compiler

For something like creating a programming language I would split a toolset into a FrontEnd part and a Backend:

The Frontend would be a Parser/Translator that reads your source code, splits it up into tokens and then according to the defined syntax rules outputs eather another readable source code in another language like C++, ASM or some kind of byte code that can be used further.

The Backend could be something like FlatAssembler, the GNU Compilers, linkers etc. These tools will take the output of the Frontend, translate it into object code and then a linker will create either an executable, a dynamic or static library. Or if you have created Byte code, it could be a virtual machine (VM) that can already run your code.
Besides a VM, I would not create a backend myself. There are great tools available on the market that save you time and more nerves. Like Flatassembler, NASM, GNU C++ compiler, PellesC, FreePascal. They do an awesome job.


For every command and syntax a own DLL and command and function declaration ? so I have done with "lion_gfx" module for thinbasic ? do you know more about such things ???

What you refer to a DLL is one technic you can use to store a runtime library of language commands inside. A lot of languages do that. But also a lot have static libraries that are linked with an object code at compile time. These runtime libraries are the meat of any language and I consider them to be the most work from the whole process. Writing, testing, documenting. Argggg :)

Google for Let’s Build a compiler by Jack Crenshaw. Or stuff from Nikolaus Wirth about compiler construction. He created great programming languages wrote great information about it. Also look into COCO/R, ANTLR and GOLD PARSER BUILDER. These are tools that will help you creating the most difficult parts of a compiling suit.

And be prepared for a looooong learning process. Btw. which platform do you want to run your thing on? Windows only?

But, what is a GraphicCompiler? Do you have a comandset to create graphics and then at runtime, it will display it? Some kind or TURTLE? At first, it sounded like a programming language. Then it sounds like a 3D app like 3DMax, then it sounds like a very specialized mark up language compiler. Can you elaborate more on what kind of application you want to create actually?

Have fun
Michael

Lionheart008
28-10-2009, 10:06
hi michael, many thanks for the infos and good links about the topic compiler and how to create a compiler. will be the right direction, I see.
unfortunatley my pc breaked down last evening, missing one important file I have deleted or copied to another place (ntldr). I don't can start my win xp at all. but that's no problem I have good friends :)

more about my compiling idea next week. best thanks, frank

zak
28-10-2009, 11:15
this is a good info Michael , i begin to read about the subject.
thanks

zlatkoAB
28-10-2009, 13:53
Guys dont forget another one which is very good
(of couse if you now C++)
http://www.briancbecker.com/bcbcms/site/proj/comptut.html

Michael Hartlef
30-10-2009, 14:25
Another great book is

Compilers and Compiler Generators, an introduction with C++ by P.D. Terry

All what I mentioned here is available for free and complete.

Lionheart008
04-11-2009, 23:55
hi all,

I have managed to build after some parts of an old c++ book (learning course with examination lesson!) a simple math. parser with visual c++ (I am still working with 2005 express edition!). the c++ beginner course ended last friday but I wanted to build an own little example. that's what I was looking for and checked for other examples and have got always the same searching routes and ways to find "flex / bison", "gold parser", "cParser" and much more. But I wanted to do this parsing project only with c++, with no other libraries or external header files. so I am on the right way now. Don't know how I am going on, but this is very satisfy to me and I am glad to see green land and sunshine before my eyes.

do some calculations ( +,-,*,/,(),=,%,^ ) , see the way of parsing and get prompted the result at the end. very simple.

if you have time or you like this "lion_parser", say it and enjoy this simple example.

edit: add strings handling in my example too ! see last picture.

good night, best regards, Frank Lionheart :)

Lionheart008
05-11-2009, 20:48
hello.

I have just included a "stringTest" (size, maxsize) in the early LionParser Example :)

and I show a part of c++ code how this work...


void analyzer::recursive1(double &culmination)
{

cout << endl << endl << " 4 Add or subtract two terms called." << endl << endl;

register char wine;
double euro;

recursive2(culmination);
while((wine = *token) == '+' || wine == '-')
{
nextToken();
recursive2(euro);
switch(wine)
{
case '-':
culmination = culmination - euro;
break;
case '+':
culmination = culmination + euro;
break;
}
}
}


the code of this example has size of "11 KB" ! :) very astonished. by the way: a real simple compiler (console modus) you can have about 800-900 code lines. that's really new for me and I wondering why does a simple compiler needs so few lines for so much calculation power (asm inclusive) ! :)

best regards, Frank