dialogos-project / dialogos

The DialogOS dialog system.
https://www.dialogos.app
GNU General Public License v3.0
20 stars 7 forks source link

warn about left-recursive grammars #199

Closed timobaumann closed 4 years ago

timobaumann commented 4 years ago

in the old days, some-commercial-ASR-plugin would crash if confronted by a left-recursive grammar. Sphinx does not crash but yields incredibly bad results (I believe it unrolls the recursion until the search beam is completely filled and has too little space for reasonable stuff left on the search beam). I believe all speech recognizer plugins will have similar issues with left-recursion.

The DialogOS grammar implementation needs a checker for left-recursion so that we can shoot a reasonable exception in this case, rather than yielding unexplainable behaviour.

timobaumann commented 4 years ago

the fix for #199 will need to be extended to cover this once the left-recursion check is implemented.

timobaumann commented 4 years ago

GrammarTest.groovy already contains a check for left recursion. The parser at present returns null for left-recursive grammars that require left recursion as part of their parse (whereas grammar creation works fine). I believe a left recursive grammar itself should not be allowed (because it's useless: when left recursion is required for the derivation, the parse will fail). Any thoughts, @alexanderkoller ?

timobaumann commented 4 years ago

there's already a Grammar.check() which does what we need. how convenient.

timobaumann commented 4 years ago

fixed. it remains to localize the error messages that were already created. That's a different issue, though.