I supposed that the only way to create my own programming language would be ASM.Am i wrong?
Also would this be possible?
Lets say i have made my own Baisc like language.When the compilers creates the EXE file,fisrt create an ASM and the make it EXE>Not directly from my compiler make an EXE but fisrt ASM and then EXE.Would this increase the speed and decrease the size of it?
'
Any recomendations on tools?
Creating a language!
Re:Creating a language!
the idea behind many things is not to start from scratch
that is, if someone has already created some sort of language,
you can use it as to implement yours
a scripting sort of thing (and never hear of asm ever again..)
that is, if someone has already created some sort of language,
you can use it as to implement yours
a scripting sort of thing (and never hear of asm ever again..)
Re:Creating a language!
If you want to make a language, you will always make a language designed on top of a different language, either direct or indirect. Direct would be through macros that transform your code into the other language's code, indirect would be that you develop a compiler that outputs a different programming language altogether. Which you make is your choice.Embrance wrote: I supposed that the only way to create my own programming language would be ASM.Am i wrong?
Also would this be possible?
Lets say i have made my own Baisc like language.When the compilers creates the EXE file,fisrt create an ASM and the make it EXE>Not directly from my compiler make an EXE but fisrt ASM and then EXE.Would this increase the speed and decrease the size of it?
'
Any recomendations on tools?
It would decrease compilation speed. By first outputting an assembly file, and then pulling it through an assembler, you have two applications, whereas you would have one. Still, it might be good for the execution performance, these assemblers have optimizations you wouldn't think about.
Tools and books: search the web for yacc, bison, flex, lex for the tools (these are compiler development tools). Try the dragon book (forgot the real name, it's got a dragon on the front page and is mentioned in the movie Hackers).
Re:Creating a language!
It's possible to create a programming language in BASIC , I did this, and it worked well, though, it's a lot more difficult.Embrance wrote: I supposed that the only way to create my own programming language would be ASM.Am i wrong?
Not directly, you can also make it that it directly translates it to machine code.Embrance wrote: Lets say i have made my own Baisc like language.When the compilers creates the EXE file,fisrt create an ASM and the make it EXE>Not directly from my compiler make an EXE but fisrt ASM and then EXE.Would this increase the speed and decrease the size of it?
What you're trying to create is a preprocessor compiler, like GCC is, I can let it translate to C, and then I can let it assemble.
I think that's what you're trying to do.
I think this method would decrease the speed, but it sure is easier to debug.
Re:Creating a language!
Note that GCC has long since ceased to be such a beast - C++ is no longer compiled to intermediate C, and has not for quite some time. The "intermediate language" of GCC is the RTL (register transfer language).DennisCGc wrote: What you're trying to create is a preprocessor compiler, like GCC is, I can let it translate to C, and then I can let it assemble.
Also note that there is a great moment for any language designer called "bootstrap" - when for the first time a compiler for your language is written in your language - since from there on, you no longer need any other languages.
Up to that point, you have to write your compiler in some other language - which that might be is completely up to you, as long as you can generate executables in it (i.e., can write files in binary format).
Every good solution is obvious once you've found it.
Re:Creating a language!
Indeed, as others have said, you can use any language whatsoever to write an interpreter or compiler for your own language.
If you write a compiler, you can also compile to whatever target-language you want, including other compiled languages. For example, many Scheme compilers have C as one of their target languages (along with possible native modes) which allows them to compile to almost any platform without special support. Whatever you do, you should probably produce some "pseudo-asm" first, possibly with block-structures, and then write a backend to actually turn that to the target language. This way most of the compilation can be left intact if you want to add another target language/native instruction-set.
Unless you are specifically targetting to a very low-level language, I would start by writing an interpreter for the language. I'd also use the most high-level language you know (say lisp is very good for this) because having an interpreter in a high-level language allows you to do changes easily.
Depending on the language, if a compiler is needed, you can then use the interpreter to write a compiler with the language itself. This has the advantage that you only need to write one compiler, and since writing an interpreter is much easier, it can save you a lot of trouble.
As for more practical approach, I'm going to write a small tutorial as soon as I get my new compiler to actually compile something.
If you write a compiler, you can also compile to whatever target-language you want, including other compiled languages. For example, many Scheme compilers have C as one of their target languages (along with possible native modes) which allows them to compile to almost any platform without special support. Whatever you do, you should probably produce some "pseudo-asm" first, possibly with block-structures, and then write a backend to actually turn that to the target language. This way most of the compilation can be left intact if you want to add another target language/native instruction-set.
Unless you are specifically targetting to a very low-level language, I would start by writing an interpreter for the language. I'd also use the most high-level language you know (say lisp is very good for this) because having an interpreter in a high-level language allows you to do changes easily.
Depending on the language, if a compiler is needed, you can then use the interpreter to write a compiler with the language itself. This has the advantage that you only need to write one compiler, and since writing an interpreter is much easier, it can save you a lot of trouble.
As for more practical approach, I'm going to write a small tutorial as soon as I get my new compiler to actually compile something.