Question:
How can I make a programming language in C/C++?
anonymous
1970-01-01 00:00:00 UTC
How can I make a programming language in C/C++?
Six answers:
horabik
2016-11-29 10:23:00 UTC
in case you may no longer cope with C, C++, or Java, then you are actually not likely to get a job as a severe coder. There are different languages alongside with Hypertext Preprocessor, yet once you may no longer do Java, you're actually not likely to get a good interest making use of the different languages. you would be a UNIX admin, yet no one is going to pay plenty for that. learn how to be a database administrator (which incorporates understanding a thank you to artwork UNIX) and you gets a good interest.
Uzma
2014-04-15 08:49:33 UTC
You can make you programes of C and C++ very easily by using the help of this site http://goo.gl/7oaaIy
samofcalifornia
2011-08-01 12:15:35 UTC
You need to understand what syntax is and what semantics is. Syntax is the recognition of the characters and semantics recognizes higher-level rules.



There are many relevant books; look for a good book but it is nearly certain that they are all too advanced for you.



There is a very classic pair of programs; Lexx and YACC. Lexx is a program for generating a lexical (syntactic) processor and YACC (Yet Another Compiler Compiler) generates a semantic processor. They can be used together; the output from the lexical processor can be the input for the semantic processor. There are public-domain versions of them available; I think the Lexx version is Flex and the YACC version is Bison. If you use the keywords "compiler syntax semantics lexx yacc" or combinations such as that then you are likely to get articles and such in the internet.



My Flex page might help; see:

http://simplesamples.info/C++/Flex.php
Don't sue me!
2011-07-24 13:50:03 UTC
You can download an open source compiler for some language to see how it's done.

http://www.google.com/search?q=open+source+compiler+written+in+c%2B%2B
SteveO
2011-07-24 13:45:15 UTC
Compilers are written in the language they are to compile and link. I hope you understand that compiler engineering is a very advanced computer science topic that is anything but easy. Writing a C/C++ compiler takes months and requires one to have an expert-level knowledge of C++ in order to properly implement it. You don't make programming languages in C++, just FYI. You design your own language and code the compiler in that language, which circumstantially requires a somewhat advanced knowledge of assembly since you have to convert tokens into assembler syntax. Google for "Dragon Book", or see if they have the dragon book at your library, and see just how hard engineering a compiler for any language really is. Once you do that, go look at the source code for the GCC compiler.
Blackcompe
2011-07-24 14:11:15 UTC
It really depends on how much of the compiler you want to implement yourself. If your trying to do everything yourself, it won't be easy. It also depends on what features you want the language to have.



Buy the Dragon book. It's really academic, but its explanations are very good. I have an older edition and I have to say it's somewhat lacking in certain parts, but when used together with say "Modern Compiler Implementation in (C or Java)" by Appel, you can get it done. Building a compiler in Java, isn't the greatest idea, but Java makes it easier. I suggest using C++, where you can leverage OO facilities for building an abstract syntax tree, although you could C structs too.



I highly recommend using a lexer generator and parser generator, where you need to learn regular expressions and context-free grammars. Because coding a parser and a lexer will be very tough, depending on their complexities. You will also need to be proficient in whatever assembly language your targeting.



Even with knowledge of all the above, it will still take a lot of hard work just to implement a procedural language. At a minimum, a working compiler written in Java for a procedural C-like language, with only three built-in data types, type checking, and name checking, is a few thousands lines of code. You should have a few years of coding experience if you want to try to do this.



I even suggest finding a university course that will assist you in designing a compiler.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...