creating a compiler for my engine using LLVM

Started by
10 comments, last by brightening-eyes 9 years, 8 months ago

hi all

as my topic title says,

i want to create a compiler for my game engine

but, i dont know how can i parse AngelScript's scripts and provide instructions for compilation with llvm

now, what you recommend to me?

what should i do?

when you can't see well like me, you can't test your applications and you can't read something

Github

Advertisement

Do you know how to use LLVM? Do you understand lexing and parsing? AST traversal, etc.?

No, then that's probably where you should start. LLVM has a short series of tutorials on using it, and there's always the dragon book.

Of course, the first stage should be Google. Or basic research. Simply tossing a bunch of words together and going "HOW I DO?" without a bit of prior research is a bad idea.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.


but, i dont know how can i parse AngelScript's scripts and provide instructions for compilation with llvm

AngelScript already has a compiler. What exactly do you hope to accomplish by writing a new one?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Washu, on 31 Jul 2014 - 1:32 PM, said:

Do you know how to use LLVM? Do you understand lexing and parsing? AST traversal, etc.?

No, then that's probably where you should start. LLVM has a short series of

tutorials on using it, and there's always the dragon book.

Of course, the first stage should be
Google. Or basic research. Simply tossing a bunch of words together and going "HOW I DO?" without a bit of prior research is a bad idea.

?

yes, if i want to create a new scripting language, i use spirit and use LLVM kaleidoscope to get started with it

and then i'll read other tutorials

?

swiftcoder, on 31 Jul 2014 - 5:26 PM, said:

brightening-eyes, on 31 Jul 2014 - 12:18 PM, said:
but, i dont know how can i parse AngelScript's scripts and provide instructions for compilation with llvm

AngelScript already has a compiler. What exactly do you hope to accomplish by writing a new one?

i want an executable compiler, something that get's the script and compile it into executable

maybe i use spirit to create a new scripting language for myself, but if you know about AngelScript, i'm here to lisson

when you can't see well like me, you can't test your applications and you can't read something

Github

Have you seen the existing Ahead-of-Time compiler for AngelScript?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Keep in mind that LLVM is not a linker, that is, it doesn't produce executable binary files by itself. That's a whole separate set of work you would need to do by hand.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

of course yes, LLVM is a compiler, and the modules must be linked together to create an executable

and about that compiler, i've saw it before

it turn's AngelScript's scripts and turn them into C++ code, and i dont need that

i want to create a compiler that turn's a set of scripts and then link it together and create an executable

when you can't see well like me, you can't test your applications and you can't read something

Github


LLVM is a compiler

LLVM is not really a compiler. It's more of an set of optimizer passes attached to an assembler, that defines a (mostly) portable assembly language, and happens to provide some libraries to help compiler developers.

You still have to write a good portion of the compiler yourself. At the very least, the lexer/parser, type checker and code-gen layers.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]


i want to create a compiler that turn's a set of scripts and then link it together and create an executable

Why?

If it's for an academic exercise, fair play to you. Go ahead and do it. Invent your own language, write the compiler, write the linker. You WILL learn a hell of a lot.

If you want it for a game, well that's a different matter.

Re-inventing the wheel is never a good thing for productivity, it's fun sometimes. If you literally re-invent the wheel, make it an octogan and change roads to have a matching set of notches, then do the maths, you find definite advantages for the new wheel over the old one.

However don't hold your breath waiting for the world to catch on and change to wheel 2.0

When it comes to games coding re-inventing the wheel nearly always ends up with coding hours wasted, productivity stalled, game delayed. It's even worse for hobby coders. Then you just see projects disappear completely.

If you want a scripting system that can be precompiled, there are plenty. You can use C# and compile it on the fly during development, then link the source code into the game for release.

You can use lua and read from hard disk during development, then package them up into binary files for release.

Hell I've even seen Forth used as a scripting system.

It's up to you in the end, but I would advise you to decide what is "Fun" for you and just code that.

i know that LLVM isnt a complete compiler, but it is a set of classes and functions to implement a compiler, you have to create your language, and then create instructions on LLVM

then link your modules together and make an executable

but, if you know something that i can use, tell me

when you can't see well like me, you can't test your applications and you can't read something

Github

This topic is closed to new replies.

Advertisement