drmfinlay / pyjsgf

JSpeech Grammar Format (JSGF) compiler, matcher and parser package for Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First alternatives cannot be tagged and repeated without additional grouping

drmfinlay opened this issue · comments

There is a parser bug where the first alternative of a set cannot be weighted and repeated simultaneously. A GrammarError will be raised if this is attempted. For example:

parse_expansion_string("/10/a+|/20/b")

This also applies to the kleene star operator (*). This doesn't occur with subsequent weighted alternatives such as /10/a|/20/b+ or /10/a|/20/b|/30/c+ because of how rule expansion parsing is done.

The problem can be sidestepped by wrapping the repetition in a required or optional grouping: /10/(a+)|/20/b or /10/[a+]|/20/b. This is not required though; I will shortly be releasing a new version that fixes this.