Make a compiler?

Posted By: upsidedownman

Make a compiler? - 03/04/09 23:55

Hi, i was wondering if it was possible to write a compiler from inside to program like FPS creator or game maker. Would this have to be done with C++ or would it be possible with lite-c?
Posted By: slacer

Re: Make a compiler? - 03/05/09 06:05

Hello,

what kind of compiler do you have in mind? FPS creator is written in dark basic and has no ingame compiler which lets you add more features to your game at runtime.
Posted By: upsidedownman

Re: Make a compiler? - 03/06/09 20:36

Well maybe i shouldn't have used fps creator for an example but like GS for example. It can compile to .exe and it is already compiled by VC++ or w/e they used. Is it possible to do this from a lite-c program or do i need to use c++ for that. When i said FPS creator i was referring to the ability to compile to an .exe. I know it is a kinda hard process but i would like to know so i can start learning toward it.
Thanks!
Posted By: MichaelGale

Re: Make a compiler? - 03/06/09 22:02

Yes, you can use Lite-C to write a compiler. However, C or C++ would be a better choice for this because they are essentially the same as Lite-C just without the reference to the engine library (which you obviously don't need to write a compiler) and without any other dependency that you don't need.

But then again, I don't quite understand what you want to do.
Posted By: upsidedownman

Re: Make a compiler? - 03/06/09 22:31

Thanks, i guess i am over my head i wanted to get started on a little test project that i create a little wrapper for lite-c with lite-c then make a compiler that could compile lite-c to an .exe file. Its just that i have been looking all over Google and can't really find a book or tutorial that gives any hints or help to creating a compiler for a language. Thanks i will keep looking.
Posted By: V_Software

Re: Make a compiler? - 03/06/09 22:32

I think right now its not possible to write an Compiler with lite-C without external libraries (that would probably be written in c++). I think you could only make an Interpreter. And this is already a huge work. Good luck and by the way don’t forget the license it says that it’s not permitted to use it for making a dll that works as a wrapper for the library by providing access to the interface structures or to library functions from outside the DLL. Maybe I didn’t understand it right but imo this tells me that its forbidden to make things like a game maker etc…but maybe u don’t even want it for such a purpose so like said before good luck. But remember a real compiler is a Program that writes special art of code and you can’t make it with a script language, the only way is C++ or Assembler ( and maybe Delphi/Pascal). Yes Acknex engine is compiled but remember the license laugh
Posted By: MichaelGale

Re: Make a compiler? - 03/06/09 23:14

Gamestudio already includes a compiler for Lite-C, you don't have to write one yourself. What do you mean with "little wrapper for lite-c"?
Posted By: upsidedownman

Re: Make a compiler? - 03/06/09 23:23

I meant a compiler from an already compiled program in lite-c(after it is distributed to an .exe file not using the GS compiler).Sorry didn't make that clear. Well i wanted to just do a test and make a few simple functions and have them be read in lite-c, i guess it isn't a wrapper really but just simplified into easier code. But if V_Software is right then i guess it is not allowed. The hole scripting language to machine code never made sense to me, my friend tried to explain it to me but i just got confused.
Posted By: amy

Re: Make a compiler? - 03/06/09 23:48

Of course it would be possible to write a compiler or interpreter with Lite-C. C compilers are written in C, Python and Lua are written in C. Lite-C is C.

I wouldn´t do this though unless you are very interested in implementing stuff like that. It should be possible to simply embed Lua or something.

I think you are right about the license issues though.
Posted By: MichaelGale

Re: Make a compiler? - 03/06/09 23:50

To be honest, I still don't quite understand you because you seem to confuse some terms. However, I think you want to use some sort of scripting or programming language as extension for your Lite-C application which is absolutely possible and legal. There are several approaches which you can use. The easiest way would probably be by including an existing library such as LUA, Python, etc.

If you really want to design your own language, you will have to write an interpreter to parse the code and something to execute the parsed instructions, most likely a virtual machine. Depending on how complex your needs are, this can be quite easy but it can also be quite hard.

Again, sorry if that's not what you want to do.
Posted By: upsidedownman

Re: Make a compiler? - 03/06/09 23:55

Yea that is basically what i am saying sorry if i was confusing, i guess you could look at it like realm crafter or game maker if you have ever seen them, they have there own language that they interpreted then you can compile an .exe file from it. I was looking to aim low to start like i said just a few functions but the part that i would be stuck on would be the compiling part. But thanks i will look into those libraries i have used LUA and Python before so it would be kinda cool so i will look into that. Thanks for your help.
Posted By: MichaelGale

Re: Make a compiler? - 03/07/09 00:16

Neither of those scripting languages supports to be compiled to a windows executable natively, however. Keep in mind that you don't have to compile it to an .exe if you want to execute it, you can do that a lot easier. If you really really want to compile them or your own language to an executable, you will indeed have to write a compiler which is a really complex thing to do. In order to do that you need to know about the structure of PE executables (windows binaries) and x86 opcodes at least. Not mentioning all the bits and pieces you need for the compiler architecture. Not an easy thing to do, but if you google for the keywords I mentioned above you may find some information on these topics.
Posted By: upsidedownman

Re: Make a compiler? - 03/07/09 00:24

Yea i figured that frown thanks for all your help, what do you mean (don't have to compile it to an .exe to run it) like for example if i were to create a program like fps creator and i were to implement my own language and let them be able to customize objects and such. Other than having it compile the game to a .exe file how would i be able to let them execute it on other machines? Again thanks for all your help.
Posted By: GamerX

Re: Make a compiler? - 03/07/09 00:33

One way you could do it is make 2 .exe's for your program one that is your program and one that is for the game then have the program copy the game.exe and have it run the users scripts and such, of course there would be more to this that you would have to figure out but this would be the essential idea. But i don't think that is legal in GS terms not sure you would have to look it up. But there is probably another way.
© 2024 lite-C Forums