Eric Mahurin wrote:
>> The major part of the cost is the construction of so many objects.
>> If you provide memoize-when-hinted, I think that'd be best.
>> If you also provided a sweet metagrammar (I find your earlier Grammar
>> examples make my eyes bleed), I'd be onto it like a shot. I need the
>> prospect of non-Ruby code generation however...
> I'm curious, could you give an example of what makes your eyes bleed?
I must admit I haven't looked closely at Grammar for a while, however...
DSLs are fine for folk who don't know how to make proper grammars

.
They tend to have a somewhat high signal-to-noise ratio, by which I mean
there are too many extraneous characters/symbols, or symbols that aren't
intuitively communicative.
Every non-essential symbol in a sentence is a significant barrier
to a newcomer, though experienced users learn to skip them and don't
understand what the fuss is about. The problem is that the difficulty
of grasping which symbols are significant and which aren't goes with
the *square* of the S/N ratio.
XML is a perfect example of how to do this wrongly

sendmail.cf
and Perl are even better examples

.
> I would like
> to provide translators from various formats (BNF, PEG, regex, etc) to
> Grammar objects.
That's what I'm talking about, good stuff.
> Also, with Grammar 0.8, I've completely separated the parser generation.
> Grammar is just a light-weight layer used to hold the description of the
> language you are parsing.
So you're already halfway to a VM, where the generated parser doesn't have
to be human-readable at all
> Personally, I don't like the idea of automatic backtracking. Regexp does
> this. The big problem I see with auto-backtracking is that when the parse
> fails, you just get a simple "it failed" response.
Not the case with Treetop. It assumes that the furthest point reached is
the failure point (not often true but an assumption that works, given...)
and lists the text leading up to that, and enumerates the terminal tokens
that would have allowed it to get further. This works *really* well.
Try it - call the "failure_reason" method on a failed parse to see it
in action.
> Nothing as simple as "expected this, got that, at line 123".
It's exactly as simple as that. The diagnosis might be wrong, but to
the human, it's a comprehensible mistake.
> Does Treetop auto-backtrack?
That's what memoizing is for - it's the core of how PEG works.
> If backtracking isn't always on, do you memoize only when you might possibly
> backtrack? In Grammar, I'm wondering if it is possible to take to a
> memoizing performance hit only when backtracking is allowed.
I don't think you can guess when backtracking will be needed.
As I said, it requires heavy analysis - Terrence didn't get his
PhD for nothing!
But if you always allow backtracking ala PEG, but only memoize in
places where experience (aka statistics collected) have shown it's
needed, you could have the best of both worlds.
> I already found it on the antlr site, but not with a ruby target. I didn't
> want to go relearn antlr (v3 now) and how to get it to generate ruby.
You just ask for Ruby in your options block at the top of the grammar.
The Ruby target is quite strange and limited though IIRC. The lexer
in all ANTLR grammars is definitely non-intuitive, it doesn't choose
the longest possible match like every other lexer in the world. Terr
isn't concerned about his users, just about big-noting himself. I
wouldn't say "their weak support ran me off" so much as just "they ran
me off". When he ****es someone off, that just proves his superiority
more... and I have the emails to prove it. You mighta thought DHH had
an attitude problem, heh, he's tame!
> Have you used ANTRWorks BTW? It's excellent!
> Once. I'd like to make something like this for Grammar (at least an engine
> that graphically displays a Grammar).
ANTLRWorks shows railroad diagrams, which I used to produce syntax
documentation for CQL. But the ability to interactively test individual
rules is great. A lot of work though - I'd have thought your skills
were better spent elsewhere.
Clifford Heath.