Feedback

  • Contents
 

Duplicate Tokens

Ensure that your grammars do not include the same token more than once. The following examples display a token replicated in two separate rules.

ABNF example of duplicate token

#ABNF 1.0;
language en-us;
mode voice;
tag-format <semantics/1.0>;
root $Example;
$Example = $Yes1 | $Yes2;
$Yes1 = (yes [sir|maam] | yeah);
$Yes2 = (yes | okay);
		

GrXML example of duplicate token

In the following example, it is possible for the yes token to match both the $Yes1 and $Yes2 rules. Creating duplicate tokens can also result from merging multiple grammars into a single grammar.

<?xml version="1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US"
root="Example"
mode="voice">
<rule id="Example">
<one-of>
<item><ruleref 
 
uri="#Yes1"/></item>
<item><ruleref 
 
uri="#Yes2"/></item>
</one-of>
</rule>
<rule id="Yes1">
<one-of>
<item>yes</item>
<item>
<one-of>
<item 
 
repeat="0-1">sir</item>
<item 
 
repeat="0-1">maam</item>
</one-of>
</item>
<item>yeah</item>
</one-of>
</rule>
<rule id="Yes2">
<one-of>
<item>yes</item>
<item>okay</item>
</one-of>
</rule>
</grammar>