On 05/01/2020 18:17, Jon Revusky wrote:
As I stated separately in an announcement, the re-activated FreeCC
project is very much in need of collaborators. Granted, people should
be interested enough on their own steam, but I have decided to sweeten
things a bit. I am defining a mini-project that I will pay $100 for.
Well, the first person who completes it, anyway. Depending on how this
turns out, I may define some other mini-projects with moderate
payouts, depending on their complexity. I don't think that this one
should be more than a day's work. Well, probably considerably less
than that. (NB. That is $100, the real ones, not Zimbabwe dollars, or
even Canadian or Australian. Coin of the imperial realm...)
Okay, the project I propose is to write a Java source code to HTML
utility using FreeCC and FreeMarker. Here is an outline of what needs
to be done to claim the grand prize. As I stated in the announcement,
FreeCC contains a Java grammar that is quite usable on its own. The
one here: https://github.com/revusky/freecc/tree/master/src/grammars
I think that things that are easy should be easy. So I provide the
steps to get going. Here is the magic incantation to build the parser
and compile it from any command line (assuming you have git and the
JDK installed. /Who doesn't?/)
|git clone https://github.com/revusky/freecc.git cd
freecc/src/grammars ../../bin/freecc Java.freecc javac
javagrammar/*.java |
Obviously, the above was meant to be 4 separate command lines:
git clone https://github.com/revusky/freecc.git
cd freecc/src/grammars
../../bin/freecc Java.freecc
javac javagrammar/*.java
The above should generate a Java parser and compile it. The generated
JavaParser class has a main() method that you can invoke via:
|java javagrammar.JavaParser |You can use that, by the way to run over
any Java source file and dump the AST.
Okay, now, there is a wrinkle to this. To work on this mini-project
actually requires a modification of the above hocus pocus. You see,
you need to use the FREEMARKER_NODES option when generating the
parser. That means that the third line of the magic incantation above
should be:
|../../bin/freecc -FREEMARKER_NODES Java.freecc |
../../bin/freecc -FREEMARKER_NODES Java.freecc
and the fourth line is also a bit more complicated because you need to
have freemarker.jar on the classpath. (Do use the one that is included
with FreeCC, by the way.) So the compile step becomes:
|javac -classpath .:../../bin/freemarker.jar javagrammar/*.java |
javac -classpath .:../../bin/freemarker.jar javagrammar/*.java
(/and the : in the above would be a semicolon ; if you are on a
Windows machine. (I know I'm spoonfeeding here, but I prefer to err on
the side of over-specification.../))
That should be simple enough. Again, if you have any questions, it is
preferable to ask them on the FreeCC discussion forum.
https://discuss.parsers.org/t/make-an-easy-100-no-this-is-not-spam/15
JR
Happy New Year,
Jon Revusky
P.S. If you decide to give it a try, you can ask for hints and so on
as well. I think the trickiest thing might be handling indentation
level. Well, also, one could get more or less ambitious with the
thing. Like, somebody who is really a whiz with HTML/javascript could
probably produce a really nice navigable version of the source code
and such. But I think I'll accept anything that is colorized and
properly indented.