Hi all.

I don't know offhand how many of the people receiving this email know who I am.  For those of you who don't, I was quite heavily involved with the FreeMarker project from some point in late 2001 to late 2008 or so. About 7 years. I was the original author of the first JavaCC grammar for FreeMarker. Before that, it was a hand-written parser.

As a result of that, and the evolution of FreeMarker, I became quite a JavaCC power user and eventually I did a lot of work on JavaCC, which I tried to donate to that project. Well, they basically refused to look at my work, so I ended up forking it and I labeled that as FreeCC.

Well, also, recently, I was trying to take a look at what was going on here and I noticed that the whole subject of parser generators came up -- this is a couple of years ago now, and nobody seemed to even know that FreeCC existed. Well, it was kind of abandoned and the only place to find it would have been on its archived Google Code site, which is still there. https://code.google.com/archive/p/freecc/

Of course, Google Code is basically defunct, so the first step to resuscitating the project was to put it on Github, which I did just yesterday. Here: https://github.com/revusky/freecc

If you want to get your hands on it and play with it, that is quite easy. It is simply:

git clone https://github.com/revusky/freecc.git

There are freecc and freecc.bat launchers that run straight out of the box since there is a "bootstrap" freecc.jar file, which is needed to do a build of freecc!

To do a build is really easy. After checking it out, it's just

cd freecc

ant

That builds a freecc.jar in the root directory that the launchers use in preference to the one in bin (if it is there, obviously...)

You can run the test cases such as they are with:

ant test

and generate some (rather limited) docs with

ant docs

In the examples, there is an example grammar for FreeMarker which I had actually intended to be the basis of the grammar in newer versions of FreeMarker. You can also eyeball those files here:

https://github.com/revusky/freecc/tree/master/examples/freemarker

Note how the FreeMarker grammar is broken into two files, FTL.freecc and FEL.freecc. The first is the grammar for directives while the second file is just for expressions, FEL being FreeMarker Expression Language. In fact, it would be fairly simple to have separate builds in which you swap in and out different FEL.freecc files and have alternative syntax for expressions. (I don't know how useful that is, but it is nifty and it is something that is, to all intents and purposes, not even possible with JavaCC, which is a much more inflexible and cumbersome tool.)

I had originally thought that, having abandoned FreeCC for a decade, that the work had no value now, since there would be so much progress over that time, but actually, I look at this, and see that, surprisingly, FreeCC could still be pretty useful, so I thought to try get it to a 1.0 release level.

Over the last few days, I've been updating the included Java grammar to handle more modern constructs. It now handles the newer try-catch blocks, the double colon :: operator, but I still haven't implemented the lambda expression syntax. But I intend to. I ran the java parser over the entire freemarker codebase and it fails on 2 files, precisely because those are the two that use lambda expressions.

Also, I fixed a couple of bugs that had been in the GoogleCode bug tracker for like 11 years.

FreeCC in its very core algorithmically is the same as JavaCC, but since it uses FreeMarker templates to generate the code, it is actually far more configurable and flexible than JavaCC. You can get an idea of the new (actually, not so new features at this point!) from these Wiki posts I wrote about 11 years ago.

https://code.google.com/archive/p/freecc/wikis

I had the beginnings of a tutorial written about 11 years ago. I put that up right here:

https://revusky.com/freecc/docs/

Well, the whole thing has quite a bit of potential, and it is a very good example of how FreeMarker can be used outside the web space, for code generation. It is quite striking to compare FreeCC's code with JavaCC and see how much more tersely and cleanly the whole thing is expressed using FreeMarker templates to generate the code of the parsers rather than the println statements approach used by JavaCC.

Well, I write this hoping that some people could really get interested in this. You might or might not, but it is easy to check out the project and play with it. There are some very old examples that are from JavaCC and then some examples I added. In particular, the included FTL.freecc and FEL.freecc are quite worthy of study, in particular, if you are interested in reworking FreeMarker.

I'll close the note here.

Best Regards,

Jonathan Revusky

Reply via email to