talonvoice / beta

Issue tracker for the private Talon Beta
10 stars 0 forks source link

Switching a mode can cause a `ParseError` #38

Closed gimpf closed 4 years ago

gimpf commented 4 years ago

When using a voice command to switch from command to dictation mode a ParseError can occur.

in-command-mode.talon:

mode: command
-
^switch to dictation mode$:
    mode.disable("command")
    mode.enable("dictation")

in-dictation-mode.talon:

mode: dictation
-
^switch to command mode$:
    mode.disable("dictation")
    mode.enable("command")

When voicing "switch to dictation mode", the following will show up in the log, and the new commands are not available:

   20: ------------------------------------# 'update' main:update_one()
   19:         talon/scripting/scope.py:121| 
   18:      talon/scripting/dispatch.py:97 | 
   17:      talon/scripting/dispatch.py:132| 
   16:      talon/scripting/dispatch.py:125| 
   15:          talon/scripting/rctx.py:174| 
   14: ------------------------------------# 'change' main:_registry_update_contexts()
   13:         talon/scripting/scope.py:51 | 
   12:      talon/scripting/registry.py:373| 
   11:      talon/scripting/dispatch.py:97 | 
   10:      talon/scripting/dispatch.py:132| 
    9:      talon/scripting/dispatch.py:125| 
    8:          talon/scripting/rctx.py:176| 
    7: ------------------------------------# 'update_speech' main:update_grammars()
    6: ------------------------------------# stack splice
    5:          talon/scripting/rctx.py:174| 
    4: talon/scripting/speech_system.py:216| 
    3:         talon/grammar/grammar.py:33 | 
    2:          talon/grammar/parser.py:184| 
    1:          talon/grammar/parser.py:175| 
talon.grammar.parser.ParseError:   Line: 1, Column: 47 - unexpected token
      (<_switch_to_command_mode_>|<_talon_sleep_> | )

Workaround: Not using start/end phrase anchors (^, $).

gimpf commented 4 years ago

This might only happen if there are only anchored commands in the file.

lunixbochs commented 4 years ago

fixed in 1274