Function declaration

Philippe Sigaud philippe.sigaud at gmail.com
Thu Dec 26 00:11:55 PST 2013


On Thu, Dec 26, 2013 at 1:16 AM,  <"Casper Færgemand\"
<shorttail at hotmail.com>"@puremagic.com> wrote:
> On Wednesday, 25 December 2013 at 21:23:23 UTC, Philippe Sigaud wrote:
>>
>> I'll consider that as a D grammar question, and not a Pegged-specific
>> question, since Pegged just uses a copy of the D site grammar :-)
>
> Thank you regardless. I'll be sure to submit some issues once we're a bit
> further down the road. Error handling is what has displeased me the most so
> far, with only a single test case ever displaying something useful. I'm not
> sure what the solution should be though, perhaps the matches that munched
> the most tokens before failing?

Error reporting in parser generator is a bit more difficult than for
hand-made parsers.
And moving around the info necessary to make a good report already
slows the parser by a factor of two.

As for what it the best report, I thought Pegged already provided the
rule that went farther?

> Also, it should be possible to detect non-munching cycles aka. left
> recursion without too much extra compile time. It's funny because it's fine
> on compile time, but instant death at runtime. I'll post some of that once
> we're further.

Yeah. I have a branch somewhere where I have many introspection
algorithms implemented (left recursion, rule reachability, null-rule
detection...). My goal is then to run them on request and block the
compilation when something is wrong.

The code is many months old already, I did not have the time to merge
it completely.See:

https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/dev/introspection.d

I'd have to test it anew, with a new DMD.

> On Wednesday, 25 December 2013 at 22:28:06 UTC, Timon Gehr wrote:A>
>> The following is a parse tree for char* format:
>> snip
>
> Oooh, I missed that. I didn't think it possible one would dissect it like
> that. In my mind it would make more sense to keep char and * together, since
> it's a type of its own. Interesting. And weird.

Yeah, it took me a long time to understand that (I now remember).
Maybe it's because D evolved from C/C++ and it inherited some strange
quirks. The resulting language is clean enough (char* is a type), but
the grammar is sometimes weird.



More information about the Digitalmars-d-learn mailing list