Re: Grammar analysis

Steven Pemberton <steven.pemberton@cwi.nl> writes:
> After adding renaming, I am now slowly adding some grammar analysis to
> ixampl.

Cool

> block: "{", rule**";", "}".
> rule: name, "=", value; .

<aside>
This rule demonstrates an aspect of our syntax that I really dislike. I
read that rule about four times before I noticed that it was a choice
between

   “name, "=", value”

and
 
   “”

I think we should introduce a required terminal for “empty”.
One candidate is ε:

 rule: name, "=", value; ε .

but there lots of other possibilities as well.
</aside>

> I'll be adding some more checks soon, but I'm happy to receive
> feedback.

I’ve added the dk.brics.grammar analyzer. It reports:

The grammar is ambiguous:
*** vertical ambiguity: $1_rule-star-sep-option[#1] <--> $1_rule-star-sep-option[#2]
    ambiguous string: ""

Which is good but also kind of unfortunately reports results based on
the underlying BNF and not the ixml grammar. (It also performs quite
poorly when presented with character classes containing a large number
of symbols, like [L].)

Perhaps we could work on building a catalog of things that are
potentially problematic. For example, Bethan had the following fragment
in a sample grammar she was using for testing her implementation:

  text: sentence.
  sentence: word+.
  @word: "a"+; "ab"; "b".

That’s not going to produce well-formed XML for any but a small subset
of inputs that would otherwise match.

What other potentially problematic grammar features would justify
warning messages?

                                        Be seeing you,
                                          norm

--
Norm Tovey-Walsh
Saxonica

Received on Friday, 25 August 2023 16:26:26 UTC