This project has moved and is read-only. For the latest updates, please go here.

Learning by example

Jul 22, 2009 at 5:44 PM

Does anyone know of an example of an Irony version of simple "hello world" language with the basic language stuff like conditionals, variable declarations, and looping? I'm trying to fast track re-learning how to design a language about 20 years after my last compiler class, and I learn best by example. Something that shows how to implement a language similar to the following example in Irony is what I'm looking for.

int a;

for a=0 to 10

if a == 5

    print "Hello, World!"

end for

Any variation on that theme (i.e. C# style for loop) would be fine. Any suggestions for books that are more up to date (and hopefully easier to read) than my 20-year-old college text book would be welcome too.

Jul 22, 2009 at 6:16 PM

You might try an article at CodeProject that demonstrates adding a new language to MS Visual Studio using has a simplified C language derivative called 'MyC' whose grammar you could use:

Ignore all the complexities of Visual Studio and just pinch the grammar file :)

Please note that Irony has been updated quite a bit since that article was written and you might have some re-factoring issues if you download the latest Irony from here.

Jul 22, 2009 at 7:34 PM

That's a good article. I'm just getting back to Irony after about a 7 month detour into wasting my time playing computer games, and that article is new since my last search on The grammar is a bit more complicated than I had in mind, but I might be able to strip out some of the bits I don't need and use it as a baseline for experimentation. It's as good a place as any to start.

Jul 22, 2009 at 7:58 PM

Video games are good to improve your hand-eye coordination...really :)

Yeah, the MyC example is the simplest C derivative I've seen so comes with the Visual Studio SDK.  I'm working on a VS addon for Digital Mars D Language, which is the most complicated one I've seen so far :)