| \ You should have received a copy of the GNU General Public License |
\ You should have received a copy of the GNU General Public License |
| \ along with this program. If not, see http://www.gnu.org/licenses/. |
\ along with this program. If not, see http://www.gnu.org/licenses/. |
| |
|
| charclass [bl-] blanks +class '- +char |
charclass [bl-] blanks +class '-' +char |
| charclass [0-9(] '( +char '0 '9 ..char |
charclass [0-9(] '(' +char '0' '9' ..char |
| |
|
| : telnum ( addr u -- flag ) |
: telnum ( addr u -- flag ) |
| (( {{ ` ( \( \d \d \d \) ` ) || \( \d \d \d \) }} blanks c? |
(( {{ ` ( \( \d \d \d \) ` ) || \( \d \d \d \) }} blanks c? |
| \( \d \d \d \d \) {{ \$ || -\d }} )) ; |
\( \d \d \d \d \) {{ \$ || -\d }} )) ; |
| |
|
| : ?tel ( addr u -- ) telnum |
: ?tel ( addr u -- ) telnum |
| IF '( emit \1 type ." ) " \2 type '- emit \3 type ." succeeded" |
IF '(' emit \1 type ." ) " \2 type '-' emit \3 type ." succeeded" |
| ELSE \0 type ." failed " THEN ; |
ELSE \0 type ." failed " THEN ; |
| |
|
| : ?tel-s ( addr u -- ) ?tel ." should succeed" space depth . cr ; |
: ?tel-s ( addr u -- ) ?tel ." should succeed" space depth . cr ; |
| \( \d \d \d \d \) {{ \$ || -\d }} )) ; |
\( \d \d \d \d \) {{ \$ || -\d }} )) ; |
| |
|
| : ?tel2 ( addr u -- ) telnum2 |
: ?tel2 ( addr u -- ) telnum2 |
| IF '( emit \1 type ." ) " \2 type '- emit \3 type ." succeeded" |
IF '(' emit \1 type ." ) " \2 type '-' emit \3 type ." succeeded" |
| ELSE \0 type ." failed " THEN cr ; |
ELSE \0 type ." failed " THEN cr ; |
| ." --- Telephone number search ---" cr |
." --- Telephone number search ---" cr |
| s" blabla (123) 456-7890" ?tel2 |
s" blabla (123) 456-7890" ?tel2 |
| |
|
| ." --- Number extraction test ---" cr |
." --- Number extraction test ---" cr |
| |
|
| charclass [0-9,./:] '0 '9 ..char ', +char '. +char '/ +char ': +char |
charclass [0-9,./:] '0' '9' ..char ',' +char '.' +char '/' +char ':' +char |
| |
|
| : ?num |
: ?num |
| (( // \( {++ [0-9,./:] c? ++} \) )) |
(( // \( {++ [0-9,./:] c? ++} \) )) |
| |
|
| : ?foobars |
: ?foobars |
| (( // \( {** =" foo" **} \) \( {++ =" bar" ++} \) )) |
(( // \( {** =" foo" **} \) \( {++ =" bar" ++} \) )) |
| IF \1 type ', emit \2 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ',' emit \2 type ELSE \0 type ." failed" THEN cr ; |
| |
|
| : ?foos1 |
: ?foos1 |
| (( // \( {+ =" foo" +} \) \( {++ =" bar" ++} \) )) |
(( // \( {+ =" foo" +} \) \( {++ =" bar" ++} \) )) |
| IF \1 type ', emit \2 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ',' emit \2 type ELSE \0 type ." failed" THEN cr ; |
| |
|
| s" foobar" ?foos |
s" foobar" ?foos |
| s" foofoofoobar" ?foos |
s" foofoofoobar" ?foos |