Antlr, Objective-C, and Me

In case you don’t know, antlr (ANother Tool for Language Recognition) is a parser generator framework.  It lets you specify a language using a grammar and then it can output the source code for actually compiling and executing that language.  I won’t go in to too much detail about how ANTLR works or how languages and grammars work, one because I’m not an expert (CS classes were a long time ago) and two because google can easily tell you the answer.  The main point of this is that ANTLR can then output that source code in a number of different target languages.

It has support for several (Java, C, C++, ruby, javascript, etc.), but is lacking support for Objective-C in the most recent version.

Well I have started trying to update the Objective-C target stuff.  This has and will be a learning experience, but here are the things to note so far:

  1. I don’t know Objective-C
  2. Objective-C is used mostly by Apple devices (Mac, IPhone) and I have no Apple devices
  3. Adding a target language implementation to ANTLR3 is pretty straight forward except for items 1 and 2
The good news is I have just made a simple calculator language (recognizes numbers, whitespace, and the 4 basic math operations) which is the language version of hello world, and antlr spit out the source code in what I believe to be valid Objective-C.
The bad news is I have no way of compiling that Objective-C to see if it is in fact valid source code.  I’m currently getting some windows ports of several things needed to run it (gcc, GNUStep, magic). I also don’t know Objective-C syntax very well so I don’t have it actually outputing any semantic meaning into the source.  This means my source parses 4 + 4 and knows it needs to call a method (send a message, wtf ever objC) with 2 numbers that adds, but doesn’t output the actual code for that method.  
So this should be interesting, I’ll keep you guys (imaginary people who read my blog) posted on my progess, and if I ever actually get the Objective-C target working for ANTLR, I’ll release it back to folks.
Side note: I know its dumb that I’m trying to do this on windows, “at least use linux” you say, but I have my reasons, none of which are technical.  I’m also aware that Objective-C is just an extension of C and can be compiled by gcc, but the main reason you use it is because of the libraries and those are mostly (other than ghetto ports mentioned above) available on Apple stuff.  So if anyone wants to donate a Mac and/or IPhone that would be great.
 

One Response

  1. residentoddball Says:

    hey, I’m not imaginary…..am I?? 😉

    If it makes you feel any better, I don’t know Objective-C either.

    As far as getting an iPhone, Michael’s mom and brother have iphones and so he is insanely jealous. I say you either nag him and convince him to go ahead and get a phone because he ought to help you…..or…..convince his mom that hers is already outdated, and so she should get a new one and give the old one to you. Long shots, yes, but I just wanted a reason to procrastinate on working this morning.

    anyhoo, see ya!
    w.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.