- From: Dave Pawson <dave.pawson@gmail.com>
- Date: Thu, 16 Dec 2021 12:12:09 +0000
- To: Norm Tovey-Walsh <norm@saxonica.com>
- Cc: ixml <public-ixml@w3.org>
Working through your expansions Norm...
On Thu, 16 Dec 2021 at 11:23, Norm Tovey-Walsh <norm@saxonica.com> wrote:
> That took me a while to get my head around too. I think it’s just part
> of the definition of repeat0 and repeat1. Note that these are different:
>
> a*"#"
>
> and
>
> a*,"#"
>
> The former can be distinguished as “factor * sep” and has the semantics
> that the spec describes for repeat0. The latter is “a*” followed by “#”.
I'm good with the latter, taking the comma as ending any repetition.
>
> Later, “hints for implementors” observes that
>
> a*"#"
>
> can be rewritten. For example:
>
> X: a*"#" .
>
> can be rewritten as
>
> X: Y .
> -Y: a+"#" ; .
which smells to my way of thinking?
That *insists* on at least one 'a' which seems incorrect?
>
> I find “the alternative that matches nothing” in the grammar quite hard
> to read. I almost wish we had a special symbol for it, like ∅. Then we’d
> have:
>
> X: Y .
> -Y: Z ; ∅ .
> -Z: a, A .
> -A: "#", a, A ; ∅ .
>
> Unless I’ve got something wrong along the way, of course.
Nothing does seem to clarify that point!
>
> All of this has turned out to be an interesting challenge for me to
> implement because I don’t think the PEP parser can be made to accept
> “nothing” as an alternative. Instead, I think (I think!) I’ve modified
> it so that it understands an optional terminal or nonterminal. So I’ll
> end up rewriting it something like this:
>
> X: Y .
> -Y: Z? .
> -Z: a, A .
> -A: ("#", a, A)? .
Is this expansion on X: a*"#" . ?
In which case I've the same objection as above?
>
> Where the optionality is addressed in the parser when candidate edges
> are selected.
>
> But now we’re into about four levels of manual rewriting so I make no
> claims of correctness!
regards
--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
Received on Thursday, 16 December 2021 12:12:33 UTC