Quote:Original post by Falling Sky
Writing a compiler (or "translator") is no easy task.
Fortunately, my language is essentially C++, but without certain features. The language doesn't give the programmer the ability to use templates, bitwise operators, classes/structs (that might change in the future, but for now I can't see why it should), ternary operators, pointers/references, exceptions, and other things. Another difference is that global, predefined variables will be prefixed with '$', and fractal attribute variables are prefixed with '@'. So the only real translating I need to do is add some name-mangling to handle variables starting with '$' or '@'. My biggest challenge is syntax validation (assuming I trash the code-completion idea).
Quote:Original post by Falling Sky
I would either suggest coding a recursive descent parser in the language of your choice OR use a compiler compiler OR use something such as Boost Spirit. It is a lexical analyzer and parser built in one and it lets you use near-EBNF grammar in actual C++ code, thus making the translation from grammar to code much easier.
I've actually spent the day reading through the Boost Spirit docs, and it seems like it would really, really help me. My project's back-end is in C++, so I could easily implement it. The only hesitation I have is the fact that my front-end is in C#, so it would be more elegant to have a C# solution. I'm seriously considering using Boost Spirit though.
Quote:Original post by Falling Sky
Oh and check out my dev journal, I just completed a BASIC to C++ "translator".
Just checked it out, and it looks interesting! I'm going to have to keep track of this project!
Quote:Original post by Telastyn
From what I understand, NetBeans is easily adaptable/plugin-able. You define your syntax in some for for it and then let other plugins deal with code completion/syntax highlighting.
Not sure if it suits your needs, or just how sane it is. A peer of mine does work in it and recommends it.
That sounds pretty neat! I'd like my solution to be more embedded into my program, but I'm going to have to look into that.
What do you guys think of building the translator in C++ with Boost Spirit, and then when the user asks to compile the program in my C# front-end, I start up the translator, tell it which file needs translating, and then have my C# front-end listen to the output from the translator and report it to the user? The translator's output would simply be errors, warnings, and status messages.