Re: JetBrains / IntelliJ IDEA v8 to Support FreeMarker!

Randall R Schulz <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Jonathan,

[ Daniel, see near the end for the answer to your questions. ]


On Wednesday 02 April 2008 09:53, Jonathan Revusky wrote:
> On Wed, Apr 2, 2008 at 5:23 PM, Randall R Schulz <[email protected]> 
wrote:
> > Hello, Jonathan,
> >
> >  On Wednesday 02 April 2008 08:07, Jonathan Revusky wrote:
> >  > ...
> >  >
> >  >
> >  > In other matters, Randall, I saw you had posted something on the
> >  > ANTLR-interest list recently. ...
> >  >
> >  > Did you ever figure out how do simulate lexical states?
> >  > Supposedly you use semantic predicates, which according to TP,
> >  > is much more powerful than lexical states, but I can't get it to
> >  > work. Did you ever figure it out?
> >
> >  I'm not sure. I wonder if that goes back to my writing a TPTP
> > parser using ANTLR 2.x or my more recent creation of a CLIF parser
> > using ANTLR 3.0. Could you send me a link to the mail archive you
> > found?
>
> http://www.antlr.org:8080/pipermail/antlr-interest/2006-November/0184
>05.html

That would probably correspond to my work on a TPTP parser using ANTLR 
2.7. I completed that without too much trouble. I think I may have been 
asking about lexical states so I could add a kind of documentation 
comment capability. In my vague recollection, I ended up with a kind of 
simple state machine overlayed on top of the lexer output so I could 
associate the proper preceding documentation comment text with the 
non-comment statements that followed.


> ...
>
> >  (I don't want to start a big flame-fest between partisans, but I
> > find
>
> The problem with ANTLR is not exactly a *lack* of docs. Terence,
> along with collaborators, have written a fair bit of verbiage on it.
> However, it's a totally disorganized mass, some of it is simply
> utterly dense and impossible to understand. Other parts of it are
> downright misleading.

This is, in my experience, the biggest criticism that can be generally 
leveled against open-source projects. So many of them, while valuable 
as software artifacts, are quite poorly documented. (But I'll add, 
quite sincerely, that FreeMarker is a welcome exception to this.) I'm 
using Grails for a Web Interface, and it suffers from exactly the same 
problem. No reference manual, disorganized, incomplete documentation, 
etc. The only way to successfully use it is to rely on the collective 
understanding of the principals and users via its mailing list.


> Terence also wrote a template engine called StringTemplate. ...
>
> (This is not a parody or a joke. See
> http://www.antlr.org/wiki/display/ST/Introduction )
>
> That's the text you get via navigating www.stringtemplate.org->main
> documentation->introduction.

Oh, I know. I've been there.

I've written parsers using JavaCC and ANTLR (version 2.7 and 3.0). I 
guess we can safely say that they each have their strengths and 
weakness.


> To what audience is the above paragraph addressed? A post-graduate
> class in computer science? Or, put another way, Is the typical
> programmer who is in the market for such a tool going to hit this
> introduction and think to himself: "Aha! Suitable formalisms! Great,
> that is exactly what I was looking for!"

You do know that Dr. Parr is a professor of computer science at the 
University of San Francisco, don't you? So I just assume he knows what 
he's talking about. I mean, I've never had a professor who didn't.


> This gives a feeling for the kind of text this guy writes. I mean,
> the ANTLR stuff is just full of all kinds of technical terms being
> used without any definition or (more importantly) example. Left
> factoring, backtracking, etc.. At various times,  surfing on amazon,
> I was like one click away from ordering Terence's book on parsing
> with ANTLR, but I always just remember stuff like this and refrained.

Well, if you're going to use ANTLR, then you probably need the book, (in 
my opinion). It's specific to ANTLR 3.0, though.


> I can't believe he would be so Machiavellian as to consciously write
> text like this on his (free) website and hold back all his
> undestandable writing for the book ...

Well, if he's a latter-day Machiavelli, he hides it well. (Which, I 
suppose, is a prerequisite.)


> >  JavaCC to be a more rational, reasoned effort while ANTLR is a
> > little more "free and easy."
>
> Well, the reason I keep wanting to have another go at ANTLR is that
> it supports multiple target languages. It can generate not just in
> java, but C# and Python. Maybe C# as well is done. There is ruby
> back-end in the works. So it's attractive to have a freemarker
> grammar written against a tool that can generate those languages.

Well, you'll need to join the ANTLR mailing list if you want to use it. 
Same as pretty much anything, these days. There's a lot of list traffic 
about C#, but I pay it no heed. But my impression is that it's not as 
well-supported as Java.


> OTOH, my honest feeling at the moment is that if you have a project
> that only targets Java and you have no foreseeable need to target
> another language, you'd have to be a masochist to use ANTLR instead
> of JavaCC.

Now he tells me...


> >  Kind of like the difference between Scala and
> >  Groovy, though probably not such a strong contrast.)
>
> Out of curiosity, which of those too is the rational, reasoned
> effort? (I haven't really looked at either one that much.)

?!? Groovy is a cowboy project and, to say the least, very "scruffy." 
Scala is a reasoned, theoretically well-founded development project and 
very "neat."

Both are general-purpose programming languages that target the JVM and 
interoperate with existing Java libraries. Scala aims to integrate 
functional programming with object-oriented programming. Scala's 
principal is Martin Odersky, one of the developers of Pizza, gcj and 
early work on generifying Java. (But I don't think he deserves blame 
for the oddball form of parametric polymorphism we now have in Java.)

Scala requires a much bigger mental shift from Java than Groovy does. 
I'm using Groovy (for the Grails front-end), but I haven't used Scala,  
yet.


> >  And while we're talking about parsers, recently I've been feeling
> > a need for a Lisp-ish s-expression-style grammar for writing FTL
> > templates. ...
>
> I've been consciously trying to make this kind of thing more
> feasible, so it's easiest probably against the code in the SVN trunk
> rather than what you have in 2.3 distro.

OK. After asking, I figured I ought to just dig in, but I checked out 
tags/2.3.12. I'll get the trunk and look at that.


> Actually, this stuff I've been playing with to get FreeMarker to
> handle Velocity syntax is the best example at the moment for what you
> want to do.  In fact, you could pretty easily do what you want, I
> think, using that stuff as a template. See:

Yeah, I thought that might be a hint / clue to how to get new surface 
syntaxes for the template specification language.


> ...
>
> Actually, if you want to work on something like this, I'll give you
> svn access and you can just put your stuff under the sandbox
> directory. (I see no reason not to "let 1000 flowers bloom" in said
> sandbox.  (Or you can store your work somewhere else of course. Just
> an idea... :-))

Well, let's hold off on that for the moment. I'm really completely 
flummoxed by my current work.


> JR


-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-

On Wednesday 02 April 2008 10:31, Daniel Dekany wrote:
> Wednesday, April 2, 2008, 5:23:26 PM, Randall R Schulz wrote:
>
> [snip]
>
> > And while we're talking about parsers, recently I've been feeling a
> > need for a Lisp-ish s-expression-style grammar for writing FTL
> > templates.
>
> [snip]
>
> Just out of curiosity, how would that look, and why do you feel need
> for it?

To the first question, I don't exactly know, at least not yet.

As to the second:

I have a variety of problems that, while distinct, can all be variously 
characterized as "pattern-directed rewritings" of one sort or another.

My requirements / constraints:

- The primary content is CLIF (Common Logic Interchange Format; 
<http://cl.tamu.edu/>). It is a very Lisp-ish notation; not literally 
Lisp, but it's at least as close to Lisp as Java is to C++.
 
- I don't want to proliferate notationals within my system.

- I need to eventually allow end users to create their own 
pattern-directed rewrite rules.


I keep trying to use Scheme macros, but they have limitations that 
continue to block my attempts. One reason I'm looking at Scheme is that 
there is a Java-embeddable Scheme implementation called SISC 
(<http://sisc-scheme.org/>).


Randall Schulz

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.