Skip to content

Not possible to set priority on rules #310

@martian-a

Description

@martian-a

The spec doesn't mention prioritisation of rules or how precedence is to be determined. This means that when I have rules that are ambiguous:

  1. I can't predict or influence which rule will take precedence over another
  2. Results are inconsistent across parsers

To illustrate point 2, see karaoke_ixml.zip which contains:

  • an iXML grammar
  • a sample input file
  • the XML generated by several iXML processors using those two inputs

The processors compared are:

No two processors returned the matching results.

Even if implementations were to continue implementing their own logic for precedence, as a grammar author it would be helpful to be able to specify which rule I expect take priority over another. So that, for example, to disambiguate the following grammar:

   song-list: group+ .
       group: (artists, songs) .
       songs: song+ .
     artists: text, line-ending .
        song: text, multiplex?, code, line-ending .
   @multiplex: -" (Multiplex)", +"true" .
       @code: -" ", [Lu], [Lu], [Nd], [Nd], [Nd], [Nd], [Nd] .

        -text: (word, " ")*, word .
        -word: [L; N; P; Sc]* .
 -line-ending: (-#a; -#d) .

I could specify that:

  • the song rule is a higher priority than the artists rule
  • the code and multiplex rules are a higher priority than the text rule

Because although Exhale (Shoop Shoop) (Multiplex) MH04561 matches both the artists and song rules, if a processor isn't going to attempt to disambiguate them by, for example, giving precedence to the rule that has the most factors, then I would like it to choose song over artists because of the priorities I specified. In the example I've provided above, that first priority rule would probably make the second redundant but extra layers of priority might be relevant in a more complex grammar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions