Browse
 
Tools
Rss Categories

Phone_Number.gram

Reference Number: AA-01080 Views: 2495 0 Rating/ Voters

Example

#ABNF 1.0;
mode voice;
language en-US;

tag-format <semantics/1.0>;

root $PhoneNumber;

$Digit = (ONE {out = "1"} |
TWO {out = "2"} |
THREE {out = "3"} |
FOUR {out = "4"} |
FIVE {out = "5"} |
SIX {out = "6"} |
SEVEN {out = "7"} |
EIGHT {out = "8"} |
NINE {out = "9"} |
(ZERO | O) {out = "0"} );|

/*
* $AreaCode resolves to a three digit string
* after semantic interpretation.
*/


$AreaCode = { out = "" } ( $Digit { out += rules.Digit } ) <3>;

/*
* $Number resolves to a seven digit string
* after semantic interpretation.
*/


$Number = { out = "" } ( $Digit { out += rules.latest() } ) <7>;

/*
* After semantic interpretation,
* $PhoneNumber resolves to a structure with two member variable strings,
* areacode (which defaults to "858"), and number.
*/


$PhoneNumber =
(
[AREA CODE | ONE]
$AreaCode { out.areacode = rules.latest() }
$Number { out.number = rules.latest() }
) |
( $Number ) { out.areacode = "858"; out.number = rules.latest() };