   So... i want to write a programming language
  So... i want to write a programming languagebasically i want it to compile into c++ and use gcc to build for w/e platform i want. I heard its best to write it in backus naur form and use a tool to create a parser. I looked and tried antlr and i couldnt get it compiling c++ code. After i use antlr or anything else (flex? bison?, i think i got one of those names wrong) how much time would it take to write my own code to make the parser output in c++?Has anyone here try something writing a language or script and use something to generate a parser? how is it and how much work is this?   
  There are at least two people on the forums writing languages, which you can read in their journals.ApochIQ's EpochTelastyn's TangentReading about their adventures might give you an idea as to the scale of the task.   ;  Unless going via C++ is absolutely necessary, I've heard good things about writing compilers that target .NET.   ;  I can generate an interpreter for a simple language in less than a day using the right tools (Menhir for parsing, OCaml for the VM). Using languages that are less expresive in the tree manipulation domain would take a bit longer. From there, writing a compiler that compiles to C++ is not very difficult, the main issues being that you need a runtime to handle memory allocation in a smart way (or design your languageso that it isn't necessary). The real difficulty is not really writing the parser and code generator: if your language is designed correctly, then the parser is a matter of typing your grammar in an adapted form (usually as a parser-generator input and a tree structure) and code generation is a tree traversal. What is hard is actually designing the language in a manner that allows easy compiler implementation while still remaining useful.   ;  I haven't gone into this topic much, except using AntlrWorks to make a java compiler for a small BNF grammar.I recommend reading the book Programming Languages: Principles and Paradigms if you haven't already.Once you write out your language in Backus Naur Form I guess you could just relate your grammar to the C++ grammar and write conversions. hmm. This could be complex though depending on your language.   ;Quote:Original post by AcidZombie24So... i want to write a programming languagebasically i want it to compile into c++ and use gcc to build for w/e platform i want. I heard its best to write it in backus naur form and use a tool to create a parser. I looked and tried antlr and i couldnt get it compiling c++ code. After i use antlr or anything else (flex? bison?, i think i got one of those names wrong) how much time would it take to write my own code to make the parser output in c++?Has anyone here try something writing a language or script and use something to generate a parser? how is it and how much work is this?The first time you do it it will be a lot of work.  There are a lot of peices to a compiler; the lexer, the parser, the AST, the symbol table, type checking, etc...  But once you've done it once the next will be quicker.  For example I wrote a parser/interpreter for a Pascal style language in C that supported strings, ints, floats, and user defined types.  This was a hand coded recursive descent parser.  It took me about 8 months working on it part time.  Then I started a rewrite in C++ and it went VERY quickly (although I didn't finish the rewrite).I believe ToohrVyk uses Ocaml; the ML's are languages that are ideally suited for creating parsers and compilers.  Thats why he can do it in a day.  I recommend learning ocaml/SML or Haskell simply for this reason (algebraic types and pattern matching are REALLY cool). Seems like I recall Antlr had C++ code generation capability, but I don't see it on the site now.  Maybe that was the 2.x version.  But it can generate C code:http://www.antlr.org/wiki/display/ANTLR3/ANTLR3+Code+Generation+-+CSo that would probably be your best bet.  I think learning a tool like Antlr will be a bet of steep learning curve but once you do learn how to use it will greatly increase your productivety.  Personally I've not used Antlr but I have used JavaCC which is similar (but not as nice).Plus I always pimp this link for an example of a recursive descent parser/interpreter:http://www.jroller.com/languages/entry/python_writing_a_compiler_and;  Honestly, unless you're just out for a challenge, don't bother. Whatever problem you want to solve is probably better solved in a different way.Creating a non-trivial language that actually does things is difficult, time consuming, and immensely complicated. If all you want is a small, domain-specific language to solve a small task, you can do it in a matter of hours if you're comfortable with basic text parsing techniques and simple recursion. On the other hand, if you're looking at anything general-purpose or complex, plan on spending many months on something that will guaranteed swallow a lot of your time and energy.Without knowing exactly why you want to do this it's hard to be specific, but chances are there are much better solutions to what you want to accomplish. There may even already be a language that does what you want.   ;  ToohrVyk: can you link me to Menhir? I failed with google.OmegaHelm: what does ML and SML stand for? and what do you mean by algebraic types and pattern matching? (i'd probably guess wrong, i keep thinking functional programming).;Quote:Original post by AcidZombie24what does ML and SML stand for? and what do you mean by algebraic types and pattern matching? (i'd probably guess wrong, i keep thinking functional programming).ML and, more specifically, Standard ML.   ;Menhir.Also peek at operational semantics with some Objective Caml examples of interpreters.   