<xvoice>

<!-- This defines key characters for use in the grammars that follow.
 Modifiers may be given for any key in the order shift, control, meta.
 To try a phonetic alphabet, rename phonetic-char to alphachar, and
 alphachar to something else. -->

<!-- If you would like lowercase letters to be prefixed with "small" change
 the line that reads 
        <modanychar> = {(capital|shift) -> shift='true'}? 
 to
        <modanychar> = {(small -> shift='false')|((capital|shift) -> shift='true')} 

 Note that comments cannot appear in CDATA sections -->

    <define name='keys'> <![CDATA[
        <keychar> = 
             minus -> '-' |equals -> '='  |under score -> '_' 
            |plus -> '+'  |left brace -> '\{' |right brace -> '\}'
            |left square bracket -> '[' |right square bracket -> ']'
            |colon -> ':' |semi colon -> ';' |at symbol -> '@'
            |tilde -> '~' |hash -> '#' |comma -> ','
            |left angle bracket -> '&lt;' |right angle bracket -> '&gt;'
            |bar -> '\|' |question mark -> '?' |front slash -> '/'
            |back slash -> '\\\\' |bang -> '!' |double quote -> '"'
            |quote -> "'" |per cent -> '%' |circumflex -> '^'
            |ampersand -> '&amp;' |dot -> '\.' |dollar -> '\$'
            |asterisk -> '*' |space -> ' ' |left bracket -> '\('
            |right bracket -> '\)' |return -> '\\r' |back space -> '\\b'
            |escape -> '&Escape;' |tab -> '\\t' |left -> '&Left;'
            |page down -> '&Page_Down;' |page up -> '&Page_Up;'
            |right -> '&Right;' |up -> '&Up;' |down -> '&Down;' .

        <alphachar> = 
            a -> 'a'    |b -> 'b' 
            |c -> 'c'   |d -> 'd'   |e -> 'e'  |f -> 'f'
            |g -> 'g'   |h -> 'h'   |i -> 'i'  |j -> 'j'
            |k -> 'k'   |l -> 'l'   |m -> 'm'  |n -> 'n'
            |o -> 'o'   |p -> 'p'   |q -> 'q'  |r -> 'r'
            |s -> 's'   |t -> 't'   |u -> 'u'  |v -> 'v'
            |w -> 'w'   |x -> 'x'   |y -> 'y'  |z -> 'z' .
        
        <phonetic-char> = 
            alpha -> 'a'      |bravo -> 'b' 
            |charlie -> 'c'   |delta -> 'd' |echo -> 'e'  |foxtrot -> 'f'
            |golf -> 'g'      |hotel -> 'h' |india -> 'i' |juliet -> 'j'
            |kilo -> 'k'      |lima -> 'l'  |mike -> 'm'  |november -> 'n'
            |oscar -> 'o'     |paris -> 'p' |quebec -> 'q' |romeo -> 'r'
            |sierra -> 's'    |tango -> 't' |uniform -> 'u' |victor -> 'v'
            |whisky -> 'w'    |x -> 'x'     |yankee -> 'y' |zulu -> 'z' .
        
        <modalphachar> = {(capital|shift) -> shift='true'}? 
            {control -> control='true'}?
            {meta -> alt='true'}? 
            {<alphachar>} -> <key char={4} {3} {2} {1} /> .

        <modanychar> = {(capital|shift) -> shift='true'}? 
            {control -> control='true'}?
            {meta -> alt='true'}? 
            {(<alphachar>|<keychar>)} -> <key char={4} {3} {2} {1} /> .

    ]]> </define>

        <!-- For example:
             three fifteen, five oh one, fifteen hundred,
             fifteen hundred thirty, fifteen hundred one,
             eighteen twenty,  nineteen oh two, oh two,
             oh eight hundred (as in 24 hour time),
             point oh oh seven five, ten point oh nine, five point
             three, three tenths, six and nine tenths, four one
             hundredths, three thousandths
             -->

    <define name='numbers'> <![CDATA[
        <one-digit> = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 .

        <two-digit> = {<one-digit>} {<one-digit>} -> {1}{2}
            | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
            | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29
            | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39
            | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49
            | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59
            | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69
            | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79
            | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89
            | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 .

        <three-digit> = {<one-digit>} hundred ->     {1}00
            | {<one-digit>} hundred {<two-digit>} -> {1}{2}
            | {<one-digit>} hundred {<one-digit>} -> {1}0{2}
            | {<one-digit>} {<two-digit>} ->         {1}{2} .

        <four-digit> = {<two-digit>} hundred ->         {1}00
            | {<two-digit>} hundred {<two-digit>} ->    {1}{2}
            | {<two-digit>} hundred {<one-digit>} ->    {1}0{2}
            | {<two-digit>} {<two-digit>} ->            {1}{2}
            | {<one-digit>} thousand ->                 {1}000
            | {<one-digit>} thousand {<one-digit>} ->   {1}00{2}
            | {<one-digit>} thousand {<two-digit>} ->   {1}0{2}
            | {<one-digit>} thousand {<three-digit>} -> {1}{2} .

        <five-digit> = {<two-digit>} thousand ->        {1}000
            | {<two-digit>} thousand {<one-digit>} ->   {1}00{2}
            | {<two-digit>} thousand {<two-digit>} ->   {1}0{2}
            | {<two-digit>} thousand {<three-digit>} -> {1}{2} .

        <six-digit> = {<three-digit>} thousand ->         {1}000
            | {<three-digit>} thousand {<one-digit>} ->   {1}00{2}
            | {<three-digit>} thousand {<two-digit>} ->   {1}0{2}
            | {<three-digit>} thousand {<three-digit>} -> {1}{2} .

        <seven-plus-digit> = {<one-digit>|<two-digit>|<three-digit>}
million -> {1}000000
            | {<one-digit>|<two-digit>|<three-digit>} million
{<one-digit>} ->  {1}00000{2}
            | {<one-digit>|<two-digit>|<three-digit>} million
{<two-digit>} ->  {1}0000{2}
            | {<one-digit>|<two-digit>|<three-digit>} million
{<three-digit>} ->{1}000{2}
            | {<one-digit>|<two-digit>|<three-digit>} million
{<four-digit>} -> {1}00{2}
            | {<one-digit>|<two-digit>|<three-digit>} million
{<five-digit>} -> {1}0{2}
            | {<one-digit>|<two-digit>|<three-digit>} million
{<six-digit>} ->  {1}{2} .

        <raw-number> =
{<one-digit>|<two-digit>|<three-digit>|<four-digit>|<five-digit>|<six-digit>|<seven-plus-digit>}
.

        <number> = {<raw-number>} -> <key char='{1}' /> .

        <point-decimal> = (point|dot)
{<one-digit>|<two-digit>|<three-digit>|<four-digit>} -> \.{1} .

        <nth-decimal> = {<one-digit>} (one)? (tenth|tenths) ->   \.{1}
            | {<one-digit>} (one)? (hundredth|hundredths)   ->   \.0{1}
            | {<two-digit>} (one)? (hundredth|hundredths)   ->   \.{1}
            | {<one-digit>} (one)? (thousandth|thousandths) ->   \.00{1}
            | {<two-digit>} (one)? (thousandth|thousandths) ->   \.0{1}
            | {<three-digit>} (one)? (thousandth|thousandths) -> \.{1}
.

        <raw-real-number> = {negative -> -}? {<raw-number>} {and
{<nth-decimal>}}? -> {1}{2}{3}
            | {negative -> -}? {<raw-number>} {<point-decimal>} -> {1}{2}{3}
            | {negative -> -}? {<point-decimal>} -> {1}{2}
            | {negative -> -}? {<nth-decimal>} -> {1}{2} .

        <real-number> = {<raw-real-number>} -> <key char='{1}' /> .

    ]]> </define>

    <vocab name='shell' expr='foo'> <![CDATA[
        <<root>> = push directory ->      <key char='pd '/>
            |pop directory ->           <key char='popd\\r'/>
            |directory ->           <key char='ls\\r'/>
            |copy ->           <key char='cp '/>
            |home directory ->           <key char='~/'/>
            |edit ->                <key char='vi '/>
            |less ->        <key char='less ' />
            |locate ->        <key char='locate ' />
            |change directory ->        <key char='cd ' />
            |directory stack ->        <key char='dirs\\r' />
            |parent ->        <key char='\.\./' />
            |history ->        <key char='h\\r' />
            |pipe ->        <key char='\|' />
            |man  ->        <key char='man ' />
            |mutt ->        <key char='mutt\\r' />
            |fetch mail ->        <key char='fetchmail\\r' />
            |exit ->        <key char='exit' />
            |tail ->        <key char='tail' />
            |system log ->        <key char='/var/log/messages' />
            |login ->        <key char='ssh ' />
            |erase line ->          <key char='u' control='true'/>
            |emacs ->          <key char='emacs\\r'/>
            |shell commands off -> <grammar name='shell' action='off' />.
    ]]> </vocab>

    <vocab name='vim' > <![CDATA[
        INCLUDE "numbers.bnf"
        INCLUDE "keys.bnf"

        <hldir> = next -> Next | previous -> Prev .
        <hlblock> = for loop -> for | while | switch | conditional -> if .
        <selaction> = highlight -> Grabobj | yank -> Yankobj .
        <seltype> = spaces -> " " | words -> "e" | lines -> "l" .
        <selection> = {<selaction>} {<raw-number>} {<seltype>} 
                -> <key char=':call {1}({3},{2})\\r' /> .
        <<root>> = editor commands off -> <grammar name='vim' action='off' /> 
            |exit ->        <key char=':q\\r' />
                <grammar name='vim' action='off' /> 
                <grammar name='shell' action='on' /> 
            |<selection>
            |highlight this block -> <key char=':Thisblock\\r' />
            |highlight {<hldir>} {<hlblock>} -> <key char=':{1}{2}\\r' />
            |move this {<raw-number>} words {left -> b\\b | right -> w\\b } -> 
                <key char="d{1}{2}p`[v`]" />
            |move this {<raw-number>} lines {up -> kk | down -> jk } -> 
                <key char="d{1}{2}p`[V`]" />
            |{(leave -> 'm' | jump to -> "'")} {global -> shift='true'}?
                mark {<alphachar>} -> <key char={1}><key char={3} {2} />
            |yank {(to register {<alphachar>} -> <key char='"' />
                    <key char={1} />)}? -> {1}<key char='y' /> 
            |put {(from register {<alphachar>} -> <key char='"' />
                <key char={1} />)}? -> {1}<key char='p' /> 
            |member ->              <key char='\.'/>
                    <key char='o' control='true'/>
                    <key char=':Getstruct\\r'/>
            |reference member ->              <key char='-&gt;'/>
                    <key char='o' control='true'/>
                    <key char=':Getstruct\\r'/>
            |pound define ->        <key char='#define '/>
            |pound include ->        <key char='#include '/>
            |static ->              <key char='static '/>
            |constant ->            <key char='const '/>
            |integer ->             <key char='int '/>
            |character ->           <key char='char '/>
            |void ->                <key char='void '/>
            |while ->               <key char='while '/>
            |switch ->              <key char='switch '/>
            |case ->                <key char='case '/>
            |else ->                <key char='else '/>
            |for loop ->            <key char='for '/>
            |regular expression ->  <key char='grep '/>
            |next function ->       <key char=':Findfunc\\r'/>
            |previous function ->   <key char=':Prevfunc\\r'/>
            |list functions ->      <key char=':Listfunc\\r\\r\\r:cl\\r'/>
            |next in list ->        <key char=':cn\\r'/>
            |previous in list ->    <key char=':cp\\r'/>
            |list element {<raw-number>} ->    <key char=':cc {1}\\r'/>
            |line numbers off ->    <key char=':set nonu\\r'/>
            |line numbers on ->     <key char=':set nu\\r'/>
            |make tags ->           <key char=':!makectags\\r'/>
            |read help ->           <key char=':help\\r'/>
                                    <key char='w' control='true'/>
                                    <key char='_'/>
            |build file ->          <key char=':make\\r'/>
            |switch buffer ->       <key char='6' control='true'/>
            |list buffers ->        <key char=':ls\\r' />
            |top of file ->         <key char='gg'/>
            |again ->               <key char='\.'/>
            |bottom of file ->      <key char='G'/>
            |erase line ->          <key char='u' control='true'/>
            |open buffer {<number>} -> {1} <key char='6' control='true'/>
            |expand ->              <key char='n' control='true'/>
            |back expand ->         <key char='p' control='true'/>
            |open file ->           <key char=':e '/>
            |undo ->                <key char='u'/>
            |end of line ->         <key char='\$'/>
            |beginning of line ->   <key char='_'/>
            |change word ->         <key char='cw'/>
            |delete word ->         <key char='dw'/>
            |delete line ->         <key char='dd'/>
            |push tag ->            <key char=']' control='true'/>
            |pop tag ->             <key char='t' control='true'/>
            |next tag ->            <key char=':tn\\r' />
            |new line ->            <key char='m' control='true'/>
            |search backward ->     <key char='?'/>
            |search ->              <key char='/'/>
            |save file ->           <key char=':w\\r'/>
            |previous ->            <key char='N'/>
            |next ->                <key char='n'/>
            |yank line ->           <key char='Y'/>
            |yank word ->           <key char='yw'/>
            |put ->                 <key char='p'/>
            |scroll back ->         <key char='u' control='true'/>
            |scroll forward ->      <key char='d' control='true'/>
            |move left {<number>} words -> {1} <key char='b'/>
            |move right {<number>} words -> {1} <key char='w'/>
            |move left {<number>} spaces -> {1} <key char='&Left;'/>
            |move right {<number>} spaces -> {1} <key char='&Right;'/>
            |move up {<number>} lines -> {1} <key char='&Up;'/>
            |move down {<number>} lines -> {1} <key char='&Down;'/>
            |jump to line {<number>} -> {1} <key char='gg'/> .
    ]]> </vocab>

    <application name='term' expr='(xterm)|(rxvt)|(aterm)|(Terminal)|(VIM.*)'> <![CDATA[
        INCLUDE "numbers.bnf"
        INCLUDE "keys.bnf"
        <<root>> = number {<number>} -> {1}
            | <modanychar> | <number> | <real-number>
            |voice commands ->   <key char='~/\.xvoice/xvoice\.xml' />
            |shell commands on -> <grammar name='shell' action='on' />
                <grammar name='vim' action='off' />
            |editor commands on -> <grammar name='vim' action='on' /> 
                <grammar name='shell' action='off' /> .
    ]]> </application>

  <application name='emacs' expr='X?emacs.*'><![CDATA[
    INCLUDE "numbers.bnf"
    INCLUDE "keys.bnf"
	<<root>> = number {<number>} -> {1}
                | <modanychar> | <number> | <real-number>
		|expand ->	<key char='/' alt='true'/>
		|open file ->	<key char='x' control='true'/>
			<key char='f' control='true'/>
		|delete buffer ->	<key char='x' control='true'/>
			<key char='k'/>
		|keyboard quit ->	<key char='g' control='true'/>
		|undo ->	<key char='_' control='true'/>
		|beginning of line ->	<key char='a' control='true'/>
		|backward character ->	<key char='b' control='true'/>
		|delete character ->	<key char='d' control='true'/>
		|end of line ->	<key char='e' control='true'/>
		|forward character ->	<key char='f' control='true'/>
		|new line and indent ->	<key char='j' control='true'/>
		|kill line ->	<key char='k' control='true'/>
		|recenter ->	<key char='l' control='true'/>
		|new line ->	<key char='m' control='true'/>
		|next line ->	<key char='n' control='true'/>
		|open line ->	<key char='o' control='true'/>
		|previous line ->	<key char='p' control='true'/>
		|search backward ->	<key char='r' control='true'/>
		|search ->	<key char='s' control='true'/>
		|transpose characters ->	<key char='t' control='true'/>
		|scroll up ->	<key char='v' control='true'/>
		|scroll down ->	<key char='v' alt='true'/>
		|kill region ->	<key char='w' control='true'/>
		|yank ->	<key char='y' control='true'/>
		|suspend emacs ->	<key char='z' control='true'/>
		|other window ->	<key char='\\t' control='true'/>
		|shell command ->	<key char='!' alt='true'/>
		|spell word ->	<key char='\$' alt='true'/>
		|query replace ->	<key char='%' alt='true'/>
		|backward sentence ->	<key char='a' alt='true'/>
		|backward word ->	<key char='b' alt='true'/>
		|kill word ->	<key char='d' alt='true'/>
		|forward sentence ->	<key char='e' alt='true'/>
		|forward word ->	<key char='f' alt='true'/>
		|go to line ->	<key char='g' alt='true'/>
		|switch to buffer ->	<key char='x' control='true'/>
			<key char='b' />
		|directory listing ->	<key char='x' control='true'/>
			<key char='d' />
		|count lines in page ->	<key char='x' control='true'/>
			<key char='l' />
		|compose mail ->	<key char='x' control='true'/>
			<key char='m'/>	
		|send mail ->	<key char='c' control='true'/>
			<key char='s' control='true'/>	
		|other window ->	<key char='x' control='true'/>
			<key char='o' />
		|save some buffers ->	<key char='x' control='true'/>
			<key char='s' />
		|save buffer ->	<key char='x' control='true'/>
			<key char='s' control='true'/>
		|compile ->	<key char='x' alt='true'/>  
			<key char='compile'/>
		|browse the web ->	<key char='x' alt='true'/>  
			<key char='w3\\r'/>
		|open location ->	<key char='o' control='true'/>  
		|widget ->	<key char='x'  alt='true'/>	
		|start section ->	<key char='cs' control='true'/>
		|boldface font ->	<key char='cfb' control='true'/>
		|slanted font ->	<key char='cfs' control='true'/>
		|emacs ->	<key char='emacs'/>
.  ]]>   </application>

  <application name='netscape' expr='Netscape.*'><![CDATA[
    INCLUDE "numbers.bnf"
    INCLUDE "keys.bnf"
        <<root>> = number {<number>} -> {1}
                | <modanychar> | <number> | <real-number>
                |back ->        <key char='&Left;' alt='true'/>
                |forward ->     <key char='&Right;' alt='true'/>
                |open page ->   <key char='o' alt='true'/>
                |close ->       <key char='w' alt='true'/>
                |new window ->  <key char='n' alt='true'/>
                |find ->        <key char='f' alt='true'/>
                |find again ->  <key char='g' alt='true'/>
                |book mark ->   <key char='k' alt='true'/>
                |reload ->      <key char='r' alt='true'/>
                |print ->       <key char='p' alt='true'/><pause/>
                                <key char='\\r'/>
                |home ->        <mouse x='237' y='55' origin='window'
button='1' action='click'  />
                |goo gull ->    <key char='o' alt='true'/><pause/>
                                <key char='ak' control='true' />
                                <key char='google\.com\\r'/>
                |x voice ->     <key char='o' alt='true'/><pause/>
                                <key char='ak' control='true' />
                                <key
char='http://xvoice\.sourceforge\.net\\r'/>
                |slash dot ->   <key char='o' alt='true'/><pause/>
                                <key char='ak' control='true' />
                                <key char='slashdot\.org\\r'/>
.  ]]>   </application>

    <application name='windowmanagershortcuts' expr='windowmanagershortcuts'> <![CDATA[
        INCLUDE "numbers.bnf"
        <<root>> = next window ->       <key char='\\t' alt='true'/>
            | last window ->            <key char='\\t' alt='true' shift='true'/>
            | move to workspace {<raw-number>} ->  <key char='{1}' alt='true'/>
            | icon if eye window ->     <key char='m' alt='true'/> .
    ]]> </application>

  <!-- These words are available in every application. -->
  <application name='general' expr='general'><![CDATA[
    INCLUDE "numbers.bnf"
    INCLUDE "keys.bnf"
	<<root>> = number {<number>} -> {1}
                | <modanychar> | <number> | <real-number>
        .
  ]]> </application>

    <vocab name='gui'> <![CDATA[
        <<root>> = dismiss .
    ]]> </vocab>
</xvoice>
