version 1.13, 2010/09/05 20:07:50
|
version 1.16, 2010/09/12 21:46:30
|
Line 17
|
Line 17
|
\ 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/. |
|
|
|
: ?depth depth IF ." unbalanced: " .s clearstack cr THEN ; |
|
|
charclass [bl-] blanks +class '-' +char |
charclass [bl-] blanks +class '-' +char |
charclass [0-9(] '(' +char '0' '9' ..char |
charclass [0-9(] '(' +char '0' '9' ..char |
|
|
Line 29 charclass [0-9(] '(' +char '0' '9' ..ch
|
Line 31 charclass [0-9(] '(' +char '0' '9' ..ch
|
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 cr ?depth ; |
: ?tel-f ( addr u -- ) ?tel ." should fail" space depth . cr ; |
: ?tel-f ( addr u -- ) ?tel ." should fail" space cr ?depth ; |
|
|
." --- Telephone number match ---" cr |
." --- Telephone number match ---" cr |
s" (123) 456-7890" ?tel-s |
s" (123) 456-7890" ?tel-s |
Line 48 s" 123 456-78909" ?tel-f
|
Line 50 s" 123 456-78909" ?tel-f
|
|
|
: ?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 ?depth ; |
." --- Telephone number search ---" cr |
." --- Telephone number search ---" cr |
s" blabla (123) 456-7890" ?tel2 |
s" blabla (123) 456-7890" ?tel2 |
s" blabla (123) 456-7890 " ?tel2 |
s" blabla (123) 456-7890 " ?tel2 |
Line 69 charclass [0-9,./:] '0' '9' ..char ','
|
Line 71 charclass [0-9,./:] '0' '9' ..char ','
|
|
|
: ?num |
: ?num |
(( // \( {++ [0-9,./:] c? ++} \) )) |
(( // \( {++ [0-9,./:] c? ++} \) )) |
IF \1 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ELSE \0 type ." failed" THEN cr ?depth ; |
|
|
s" 1234" ?num |
s" 1234" ?num |
s" 12,345abc" ?num |
s" 12,345abc" ?num |
Line 90 s" Hier kommt nichts vor" ?string
|
Line 92 s" Hier kommt nichts vor" ?string
|
|
|
: ?foos |
: ?foos |
(( \( {** =" foo" **} \) )) |
(( \( {** =" foo" **} \) )) |
IF \1 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ELSE \0 type ." failed" THEN cr ?depth ; |
|
|
: ?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 ?depth ; |
|
|
: ?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 ?depth ; |
|
|
s" foobar" ?foos |
s" foobar" ?foos |
s" foofoofoobar" ?foos |
s" foofoofoobar" ?foos |
Line 112 s" fofoofoofofooofoobarbar" ?foobars
|
Line 114 s" fofoofoofofooofoobarbar" ?foobars
|
s" bla baz bar" ?foobars |
s" bla baz bar" ?foobars |
s" foofoofoo" ?foobars |
s" foofoofoo" ?foobars |
|
|
s" foobar" ?foos1 |
\ s" foobar" ?foos1 |
s" foofoofoobar" ?foos1 |
\ s" foofoofoobar" ?foos1 |
s" fofoofoofofooofoobarbar" ?foos1 |
\ s" fofoofoofofooofoobarbar" ?foos1 |
s" bla baz bar" ?foos1 |
\ s" bla baz bar" ?foos1 |
s" foofoofoo" ?foos1 |
\ s" foofoofoo" ?foos1 |
|
|
|
\ backtracking on decissions |
|
|
|
: ?aab ( addr u -- flag ) |
|
(( {{ =" aa" || =" a" }} {{ =" ab" || =" a" }} )) ; |
|
s" aab" ?aab 0= [IF] .( aab failed!) cr [THEN] |
|
|
\ buffer overrun test (bug in =") |
\ buffer overrun test (bug in =") |
|
|
Line 164 s" delete (test) and (another test) " de
|
Line 172 s" delete (test) and (another test) " de
|
\3 s>number drop + 0 <# 's' hold #s #> //g ; |
\3 s>number drop + 0 <# 's' hold #s #> //g ; |
|
|
s" bla 12:34:56 fasel 00:01:57 blubber" 2dup type hms>s |
s" bla 12:34:56 fasel 00:01:57 blubber" 2dup type hms>s |
." replaced by " 2dup type |
." -> " 2dup type |
s" bla 45296s fasel 117s blubber" str= [IF] .( ok) [ELSE] .( failed) [THEN] cr |
s" bla 45296s fasel 117s blubber" str= [IF] .( ok) [ELSE] .( failed) [THEN] cr |
|
|
: hms>s,del() ( addr u -- addr' u' ) |
: hms>s,del() ( addr u -- addr' u' ) |
Line 172 s" bla 45296s fasel 117s blubber" str= [
|
Line 180 s" bla 45296s fasel 117s blubber" str= [
|
>> \1 s>number drop 60 * |
>> \1 s>number drop 60 * |
\2 s>number drop + 60 * |
\2 s>number drop + 60 * |
\3 s>number drop + 0 <# 's' hold #s #> << |
\3 s>number drop + 0 <# 's' hold #s #> << |
|| ` ( {* .? *} ` ) >> <<" " |
|| ` ( // ` ) >> <<" " |
}} LEAVE //s ; |
}} LEAVE //s ; |
|
|
\ doesn't work yet |
\ doesn't work yet |