Consider the following Vocola file:
##
## Test handling of words containing backslashes:
##
#
# These behave like the lists denote the empty string:
#
<y> := ( "/" | "\\" );
test type <y> = $1;
<z> := ( "/" | "\" );
test foo <z> = $1;
<x> := (white |"yellow " | "orange ");
Fred test <x> = $1;
#
# These aren't recognizable:
#
test Fred "\" = George;
omega test "red " = blue;
Delta test (white |"yellow " | "orange ") = $1;
#
# this one works fine:
#
alpha test = normal;
It converts to the following NatLink file:
# NatLink macro definitions for NaturallySpeaking
# Generated by vcl2py 2.5.3, Fri May 11 20:06:58 2007
import natlink
from natlinkutils import *
from VocolaUtils import *
class ThisGrammar(GrammarBase):
gramSpec = """
<y> = ('/' | '\\\\' ) ;
<1> = 'test type' <y> ;
<z> = ('/' | '\\' ) ;
<2> = 'test foo' <z> ;
<x> = ('white' | 'yellow ' | 'orange ' ) ;
<3> = 'Fred test' <x> ;
<4> = 'test Fred \\' ;
<5> = 'omega test red ' ;
<6> = 'Delta test' ('white' | 'yellow ' | 'orange ' ) ;
<7> = 'alpha test' ;
<any> = <1>|<2>|<3>|<4>|<5>|<6>|<7>;
<sequence> exported = <any>;
"""
def initialize(self):
self.load(self.gramSpec)
self.currentModule = ("","",0)
self.ruleSet1 = ['sequence']
def gotBegin(self,moduleInfo):
window = moduleInfo[2]
self.firstWord = 0
# Return if same window and title as before
if moduleInfo == self.currentModule: return None
self.currentModule = moduleInfo
self.deactivateAll()
title = string.lower(moduleInfo[1])
if string.find(title,'') >= 0:
for rule in self.ruleSet1:
self.activate(rule)
def get_y(self, word):
actions = Value()
actions.augment(word)
return actions
# test type <y>
def gotResults_1(self, words, fullResults):
actions = Value()
word = fullResults[1 + self.firstWord][0]
actions.augment(self.get_y(word))
actions.perform()
self.firstWord += 2
def get_z(self, word):
actions = Value()
actions.augment(word)
return actions
# test foo <z>
def gotResults_2(self, words, fullResults):
actions = Value()
word = fullResults[1 + self.firstWord][0]
actions.augment(self.get_z(word))
actions.perform()
self.firstWord += 2
def get_x(self, word):
actions = Value()
actions.augment(word)
return actions
# Fred test <x>
def gotResults_3(self, words, fullResults):
actions = Value()
word = fullResults[1 + self.firstWord][0]
actions.augment(self.get_x(word))
actions.perform()
self.firstWord += 2
# test Fred \\
def gotResults_4(self, words, fullResults):
actions = Value()
actions.augment('George')
actions.perform()
self.firstWord += 1
if len(words) > 1: self.gotResults_4(words[1:], fullResults)
# omega test red
def gotResults_5(self, words, fullResults):
actions = Value()
actions.augment('blue')
actions.perform()
self.firstWord += 1
if len(words) > 1: self.gotResults_5(words[1:], fullResults)
# Delta test (white | yellow | orange )
def gotResults_6(self, words, fullResults):
actions = Value()
word = fullResults[1 + self.firstWord][0]
actions.augment(word)
actions.perform()
self.firstWord += 2
if len(words) > 2: self.gotResults_6(words[2:], fullResults)
# alpha test
def gotResults_7(self, words, fullResults):
actions = Value()
actions.augment('normal')
actions.perform()
self.firstWord += 1
if len(words) > 1: self.gotResults_7(words[1:], fullResults)
thisGrammar = ThisGrammar()
thisGrammar.initialize()
def unload():
global thisGrammar
if thisGrammar: thisGrammar.unload()
thisGrammar = None
Inspection of the grammar shows that "test foo" and "test type" are not valid commands, yet they are recognized anyway. Somehow words like '\', '\\', and 'red ' break the grammar silently.
Is this a DNS bug, in which case it would be nice to know which words cause the problem. Or, is NatLink ignoring an error status code from DNS?
- Mark
mdl@alum.mit.edu
Logged In: YES
user_id=837135
Originator: NO
Mark, please restate the question if it is still active.
Quintijn
Is this still an issue? Quintijn