So I am trying to make a small programming language as a project. But the thing is I have no clue how to begin. I know how a compiler works and all but don't know how the code would be written for it. I searched everywhere for example for the code of any compiler but couldn't find anything. Where would I find this, or could someone explain to me the format and method I should use for creating the compiler? Also if you were wondering I am thinking of using c++ for writing the compiler.
I recommend taking a free online course in Compiler Construction. Guided material and thoughtfully designed coursework is the best way to ease into this sort of thing, in my opinion.
LLVM.org; open source modern C, C++, Objective-C and more
Related
I am working on a Genetic Algorithm solution to TSP in Lua, and have reached a point where I need a better method of troubleshooting and checking results. The best way to do this would be with a GUI, but I can't seem to find anything about GUIs in Lua.
I've done some searching around Google, and haven't found anything built in to the language. I have found Toolkits such as the one found here:
http://lua-users.org/wiki/GraphicalUserInterfaceToolkits
However, I am new enough to Lua that I do not know how to properly use these. Any help on the matter would be greatly appreciated.
A few ideas:
But first, what platform are you on?
Are you constrained by platform? If not, I've done very exciting things directly on an iPad, in Codea. Pure Lua, built on OpenGL, so built-in API for graphics support.
Beyond that, you could probably use Love2d. It's meant for game dev, but you could probably adapt it to your needs. It's a Lua API, has graphics support, and is cross-platform. I don't know much about it (yet), so others could pipe in with their thoughts/opinions.
If you are still shaky in Lua, I suggest to stick to the console for a while. GUI, whatever the language, is usually messy and unsatisfying for beginners.
If you already know some HTML and Javascript, consider using Lua with a web framework, and using the browser to control your program through a REST API:
Awesome-Lua#Web/Networking Platforms
Apart from that, I have yet to find a GUI framework that feels right for Lua. Almost everything is a thin wrapper around a C or C++ API and handles exactly like that. On the other hand, with the web and Electron on the rise there seems little need for it.
Unfortunately, my C app for PIC32 needs OO too much and I can't continue doing it in C.
Do you know any MIPS32 C++ compiler for PIC32?
Thanks
Microchip's XC32 tool chain now supports C++ since version 1.10
You might contact Comeau Computing; thier C++ compiler generates C code as an intermediate language so that it can then utilise a platform's existing native C compiler where only a C compiler is available, and therefore porting to new platforms is relatively quick and simple.
For various reasons the intermediate generation and compiler adaptation is not accessible to end users so you will still need Comeau to generate a PIC32/C32 port, but it probably won't take long and hopefully they would amortise the cost over sales to other users.
However if you use Commeau or any other C++ to C translator, you will suffer from the inability to use source-level debugging, and that is likley to be the killer to any attempt to use C++ sucessfully without native debugger support.
Although it is not always pretty, your best bet is probably to learn how to implement OO designs in C. Here's a whole book on the subject: http://www.planetpdf.com/codecuts/pdfs/ooc.pdf
According to this fairly recent thread on the microchip forums it looks like C++ support for PIC32 isn't available anywhere yet and isn't a high priority with Microchip. The wisdom of the respondents in that thread appears to be: don't hold your breath.
I'm a MPLAB user myself building small programs so I just take what Microchip gives me. I've never gotten to the point where I thought I needed C++, longed for yes, but never needed. As a next step you can either consider moving to another platform with C++ support or take another look at your design and ask why you need C++ that badly. Some features can be simulated in C with varying amounts of pain and suffering.
You might keep an eye on the proper GCC MIPS port. They have all the pieces, but I don't know if anyone's made C++ work with PIC32 in particular. I know it did work on sgimips.
I'm developing a c++ application with Xcode 3.1.4
while debugging, if i step into a constructor, i see only the membervariables, but no locals used in the constructor.
does anyone know that problem and how to solve it?
I saw somewhere else that -gstabs+ solves a similar problem specific to locals in constructors. I didn't try it but the solution that worked for me was to move the body of the code into a private function with the same arguments, and call that function from the constructor. Same behavior, but now you can debug the code...
It may be a bug in the compiler such as this one. You could try upgrading your g++ or using a different compiler.
Obvious question: you're running with no optimizations (-O0), correct? With optimizations, it is very common for local variables to be optimized out. Even without optimizations, I have found that a lot of simple C++ seems to get hidden. For instance, you can't always call get() on a shared_ptr because it gets inlined.
I recommend upgrading to Xcode 3.2. I feel that C++ support improved somewhat between 3.1 and 3.2. That said, C++ support within Xcode is still very weak. Unless you need the portability of C++ (as I do), I do not recommend developing Mac or iPhone apps in C++. You will fight the system all day. It is far better to just learn ObjC and use it (besides, ObjC really is a very powerful language and works extremely well with Cocoa). Even when you need the portability of C++, I recommend isolating the C++ code into a core and wrapping it up in Objective-C.
In no case should you use much ObjC++. gdb gets extremely confused in my experience with ObjC++. If you're going to write in C++, wrap your ObjC. If you're going to write in ObjC, wrap your C++. But don't try to write in both at the same time if you ever plan to use the debugger.
I'm writing a compiler that converts source code (written in a small imperative programming language) to Intel AT&T 32-bit assembler.
I tend to spend a lot of time debugging, because of nasty offset-mistakes etc. in the generated code, and I would like to know if anyone knows of a tool to "walk through" the generated assembler code step-by-step, visualizing what's on the stack etc.
I use Ubuntu Linux as my development platform, and I'm comfortable with the terminal -- a GUI-program would be nice though. Does it exist? Or is there a good reason it doesn't (maybe the problem isn't so straightforward..?)
If you have good ideas for approaching debugging tasks in assembly code, I'll be glad to hear from you!
I like EDB (Evan's Debugger) on Linux. It has a nice, easy-to-use, QT4-based GUI. Its developer's goal is to make it similar to OllyDbg. And it's being actively maintained:
EDB on FreshMeat
I'm pretty sure it's installable through Synaptic on Ubuntu as well. Enjoy!
Is the end result of the compile process something that you can actually execute, and therefore examine in a debugger? If so the Data Display Debugger (ddd) might be useful.
My experience with debuggers such as Olly and EDB is quite sparse, so I wasn't able to solve my problem with those. I ended up
scattering calls around to a Debug function in the source code, nailing down bad register values
letting the compiler output HTML-formatted code with useful metadata for different iterations in the liveness analysis etc.
There is a LEDA program.
http://www.algorithmic-solutions.com/
which basically provides GUI to algorithms. I d like to get into that, I was curious if I can code with C# or JAVA for LEDA. I have looked at their website and googled it. But i didnt see any other languages beside c/c++,
Does anyone know if i can use C# or Java for LEDA?
LEDA is a C++ library. You could, theoretically, write wrappers to use this from Java or C#, but there are none included.
All of the samples will all require C++.