Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Objective-C target

Author

Alan Condit

acondit(at)alansmachineworks(dot)com

Derived from work by:

Kay Röpke
kroepke(at)classdump(dot)org

Status

The current ANTLR beta release includes a working Xcode plugin, so you can automatically generate your grammars from within Xcode.
It automatically tracks all the dependencies between the different grammars in your project to build them in the right order.
Common error messages and warnings are picked up for display in Xcode using the new -message-format gnu option in ANTLR.
There remain some errors and warnings which cannot be picked up yet, due to missing information in ANTLR itself, but this will may change in the future.
Debugging support for use with ANTLRWorks is done, except for exceptions (wink) I just haven't got around to do it yet. The socket handling code isn't error proof yet, I will add more thorough error handling for the final version. Other than that it works beautifully!I am currently catching up with the v3 release.

ANTLR.framework

Features (partially) missing are:

...

  • Template support (postponed because there is no ST grammar for ANTLR v3 yet)
  • Debugging support for exceptions (Objective-C exceptions must match the exact names of the Java exception classes)

...

  • Single rule return values
  • FOLLOW sets (bitsets)
  • cyclic DFAs
  • Scopes
    • dynamic scopes
    • rule parameters
  • Labels
  • Syntactic Predicates
  • Semantic predicates
  • Tree support (output=AST)
  • Tree parsers
  • Debugging support for parsers.
  • Debugging support for AST building.

ANTLR Xcode plugin (Kay's work. I have done nothing with this other than use it.)

Features missing:

  • Syntax highlighting & function popup support (I'd still encourage you to use ANTLRWorks for development!) For this I need more understanding of the dreaded classes Xcode uses internally, to be able to replace them with ANTLR3 (smile)
  • Debugging (long term goal)

...

Building ASTs and tree parsers is working now. ANTLR.framework is known built to be Universal, but only tested on Intel machine.
I will use am using v3 to write a number of different small applications in order to find out about all the small bugs that are hiding in the corners. Thus development will probably not be milestone based, but rather fix-as-they-come-upsmall application. I will fix bugs as I become aware of them.
Regarding the template output support of v3, this will require an Objective-C implementation of ST , which will take a lot of time. So don't expect that for 3.0and I am not working on that, but help is always welcome.
I have added debugging support for parsers, to be used with ANTLRWorks. ANTLRWorks does not generate ANTLRWorks generating code for Objective-C based grammars yet, for that but you still will have to use the command line tool, or to rebuild the ANTLRWorks jar to use it. You can also use the Xcode 2.4
plugin, which is part of the latest beta releaseavailable for download via link here . I have put up binaries binary runtime framework on my page (see above). Contact me if you need newer versions.

Platforms

I will only concern myself with the Mac. There will be no GNUStep support.
As for Mac OS versions, I aim to be compatible with at least 10.3 6 as a target platform , though and the Xcode project will require the latest version availablewas built with 3.2.3, since it really doesn't make a lot of sense to use it in an earlier version.

The Xcode plugin requires at least Xcode 2.3.
Currently ANTLR requires 10.4. Unless   However, unless there are very good reasons to support versions prior to that10.6, it will not get priority.
. I don't have a machine on which to test earlier versions. Right now I have no plans for am working on Snow Leopard (10.5) as I don't have access to it6). I expect the current version to "just work".

Runtime

The runtime will be is built in terms of the NS* level of classes, and is probably not very optimized in the first versions. I'll identify hotspots later and maybe add a CF-based runtime for speed if it turns out to be a problemlargely a fairly direct translation of the original java code.
The layout of the runtime is essentially the same as the Java version, though subtle differences will be visible where it makes it more natural to the Objective-C programmer. Naming of classes and methods may be slightly different and sometimes inner workings are too.
Initial tests don't show serious performance problems, though I'm sure there will be opportunities for optimization.
The biggest problem at the moment are the numerous unused variables created at the moment. Often ANTLR will build up lists of tokens but subsequently not use them in any significant way, which leads to wasting time and space. This can only be fixed in the ANTLR code generator and not for individual targets. Part of the support for this is already there but it needs to be extended.

...

The goal is to provide the complete set of Java-based examples in Objective-C for comparison. There may be additional examples contained in the Xcode project. These exist mainly for development purposes as testcases, or to try out features.
The StringTemplate Editor will have to wait, as I have been hitting a major roadblock in ANTLR. Until that is sorted out, there's no point in trying to do the ST port to Objective-C.
Also take a look at the Xcode plugin that uses a filtering lexer written using ANTLR to figure out grammar types and dependencies.