Question

I have to recognize some alternative rules, but I don't know how to do a mutual exclusion. For example, if I want to recognize "play", "stop", or "set 1", "set 2", how can I do? I tried something like this, but it doesn't recognize when I don't need the number (for example, "start 2" is correctly recognized, but trivially I don't want to).

<grammar version="1.0" tag-format="semantics/1.0" xml:lang="en-US" root="main">
<rule id="main">
    <ruleref uri="#actions"/>
    <ruleref uri="#numbers"/>
</rule>
<rule id="actions">
    <item repeat="0-1">
        <one-of>
            <item>play</item>   
            <item>stop</item>
            <item>set</item>
        </one-of>
    </item>
</rule>
<rule id="numbers">
    <item repeat="0-1">
        <one-of>
            <item>1</item>
            <item>2</item>
            <item>3</item>
            <item>4</item>
            <item>5</item>
            <item>6</item>
            <item>7</item>
            <item>8</item>
            <item>9</item>
        </one-of>
    </item>
</rule>
</grammar>
Was it helpful?

Solution

Simply I found out that if I put

<item>play <ruleref special="GARBAGE"/></item>
<item>stop <ruleref special="GARBAGE"/></item>      
<item>set <ruleref special="GARBAGE"/><ruleref uri="#numbers"/></item>

calling the id reference after set will take just "set 1", "set 2", but doesn't accept "start 1" because there isn't the reference after the name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top