LIB_US_MONEY [ ; fifty, fifty three dollars even, one hundred dollars ( SUB_DOLLAR_OPTIONAL_AMOUNT:d ?SUB_EVEN ) {return([])} ; one fifty even ( SUB_DIGIT_ONE_THRU_NINE:h SUB_MONEY_THRU_99_WITH_OH:u SUB_EVEN ) {return([])} ; two bucks, a hundred bucks (small and round amounts only) SUB_BUCKS_AMOUNT:d {return([])} ; a buck twenty five (only place buck is allowed with non-zero cents) ( a buck SUB_MONEY_THRU_99:c ) {return([ ])} ; sixty two cents, no dollars and nine cents ( ?( [ no zero ] ?( dollars ?and ) ) SUB_MONEY_THRU_99:c cents ) {return([])} ; one cent ( ?( [ no zero ] ?( dollars ?and ) ) one cent ) {return([])} ; five dollars and twenty seven cents, four dollars thirty cents ( SUB_DOLLAR_REQUIRED_AMOUNT:d ?and SUB_MONEY_THRU_99:c cents ) {return([ ])} ; five dollars and one cent, four dollars one cent ( SUB_DOLLAR_REQUIRED_AMOUNT:d ?and one cent ) {return([ ])} ; forty two oh six ( SUB_MONEY_THRU_99:d SUB_MONEY_THRU_99_WITH_OH:c ) {return([ ])} ; one hundred seventeen twenty ( SUB_DIGIT_ONE_THRU_NINE:h hundred ?and SUB_MONEY_THRU_99:u SUB_MONEY_THRU_99_WITH_OH:c ) {return([ ])} ; five thirty four fifty, one oh four ninety nine ( SUB_DIGIT_ONE_THRU_NINE:h SUB_MONEY_THRU_99_WITH_OH:u SUB_MONEY_THRU_99_WITH_OH:c ) {return([ ])} ; ten million dollars, just to make the end point a round number ( ten million [ dollars bucks ] ) {return([])} ] SUB_DOLLAR_REQUIRED_AMOUNT [ ( [ a one ] dollar ) {return(1)} ( SUB_DOLLARS_AMOUNT:d dollars ) {return($d)} ] SUB_DOLLAR_OPTIONAL_AMOUNT [ ( one ?dollar ) {return(1)} ( a dollar ) {return(1)} ( SUB_DOLLARS_AMOUNT:d ?dollars ) {return($d)} ] SUB_DOLLARS_AMOUNT [ ( ?a hundred ) {return(100)} ( ?a thousand ) {return(1000)} ( ?a million ) {return(1000000)} SUB_MONEY_THRU_999:d {return($d)} ( SUB_MONEY_THRU_999:t thousand ) {return(mul(1000 $t))} ( SUB_MONEY_THRU_999:t thousand SUB_MONEY_THRU_999:u ) {return(add(mul(1000 $t) $u))} ( SUB_TEEN:h hundred ) {return(mul(100 $h))} ( SUB_DECADE:t SUB_DIGIT_ONE_THRU_NINE:h hundred ) {return(mul(100 add($t $h)))} ( SUB_TEEN:h hundred ?and SUB_MONEY_THRU_99:u ) {return(add(mul(100 $h) $u))} ( SUB_DECADE:t SUB_DIGIT_ONE_THRU_NINE:h hundred ?and SUB_MONEY_THRU_99:u ) {return(add(mul(100 add($t $h)) $u))} ( SUB_DIGIT_ONE_THRU_NINE:m million ) {return(mul(1000000 $m))} ( SUB_DIGIT_ONE_THRU_NINE:m million SUB_MONEY_THRU_999:u ) {return(add(mul(1000000 $m) $u))} ( SUB_DIGIT_ONE_THRU_NINE:m million SUB_MONEY_THRU_999:t thousand ) {return(add(mul(1000000 $m) mul(1000 $t)))} ( SUB_DIGIT_ONE_THRU_NINE:m million SUB_MONEY_THRU_999:t thousand SUB_MONEY_THRU_999:u ) {return(add(mul(1000000 $m) add(mul(1000 $t) $u)))} ] SUB_BUCKS_AMOUNT [ ( SUB_MONEY_THRU_999:d bucks ) {return($d)} ( a hundred bucks ) {return(100)} ( SUB_TEEN:h hundred bucks ) {return(mul(100 $h))} ( SUB_DECADE:t SUB_DIGIT_ONE_THRU_NINE:h hundred bucks ) {return(mul(100 add($t $h)))} ( a thousand bucks ) {return(1000)} ( [ SUB_DIGIT_ONE_THRU_NINE:h SUB_TEEN:h ] thousand bucks ) {return(mul(1000 $h))} ( SUB_DECADE:t SUB_DIGIT_ONE_THRU_NINE:h thousand bucks ) {return(mul(1000 add($t $h)))} ( a million bucks ) {return(1000000)} ( SUB_DIGIT_ONE_THRU_NINE:m million bucks ) {return(mul(1000000 $m))} ] SUB_MONEY_THRU_999 [ SUB_MONEY_THRU_99:d {return($d)} ( SUB_DIGIT_ONE_THRU_NINE:h hundred ) {return(mul(100 $h))} ( SUB_DIGIT_ONE_THRU_NINE:h hundred ?and SUB_MONEY_THRU_99:u ) {return(add(mul(100 $h) $u))} ] SUB_MONEY_THRU_99 [ SUB_DIGIT_ONE_THRU_NINE:d {return($d)} SUB_TEEN:d {return($d)} ten {return(10)} SUB_DECADE:t {return($t)} ( SUB_DECADE:t SUB_DIGIT_ONE_THRU_NINE:u ) {return(add($t $u))} ] SUB_MONEY_THRU_99_WITH_OH [ ( oh SUB_DIGIT_ONE_THRU_NINE:n ) {return($n)} SUB_TEEN:n {return($n)} ten {return(10)} SUB_DECADE:t {return($t)} ( SUB_DECADE:t SUB_DIGIT_ONE_THRU_NINE:u ) {return(add($t $u))} ] SUB_EVEN [ even exactly ( ?point [ no zero ] cents ) ] SUB_DIGIT_TWO_THRU_NINE [ two {return(2)} three {return(3)} four {return(4)} five {return(5)} six {return(6)} seven {return(7)} eight {return(8)} nine {return(9)} ] SUB_DIGIT_ONE_THRU_NINE [ one {return(1)} SUB_DIGIT_TWO_THRU_NINE:n {return($n)} ] SUB_DIGIT [ [ zero oh ] {return(0)} SUB_DIGIT_ONE_THRU_NINE:n {return($n)} ] ; Single-digit grammars that return string values SUB_DIGIT_TWO_THRU_NINE_STRING [ two {return("2")} three {return("3")} four {return("4")} five {return("5")} six {return("6")} seven {return("7")} eight {return("8")} nine {return("9")} ] SUB_DIGIT_ONE_THRU_NINE_STRING [ one {return("1")} SUB_DIGIT_TWO_THRU_NINE_STRING:n {return($n)} ] SUB_DIGIT_STRING [ [ zero oh ] {return("0")} SUB_DIGIT_ONE_THRU_NINE_STRING:n {return($n)} ] SUB_TEEN_STRING [ eleven {return("11")} twelve {return("12")} thirteen {return("13")} fourteen {return("14")} fifteen {return("15")} sixteen {return("16")} seventeen {return("17")} eighteen {return("18")} nineteen {return("19")} ] SUB_DECADE_STRING [ twenty {return("2")} thirty {return("3")} forty {return("4")} fifty {return("5")} sixty {return("6")} seventy {return("7")} eighty {return("8")} ninety {return("9")} ] SUB_TEEN [ eleven {return(11)} twelve {return(12)} thirteen {return(13)} fourteen {return(14)} fifteen {return(15)} sixteen {return(16)} seventeen {return(17)} eighteen {return(18)} nineteen {return(19)} ] SUB_DECADE [ twenty {return(20)} thirty {return(30)} forty {return(40)} fifty {return(50)} sixty {return(60)} seventy {return(70)} eighty {return(80)} ninety {return(90)} ]