\ 2012-04-06 fsm2.fs include lib/ans94/postpone.frt include case.fs include tempbuffer.fs variable mystate : digit? [char] 0 [char] 9 within ; : dpoint? [char] . = ; : minus? [char] - = ; : (0) ( c -- ) dup digit? over minus? or if append 1 mystate ! else dup dpoint? if append 2 mystate ! else drop then then ; : (1) ( c -- ) dup digit? if append ( 1 mystate ! ) else dup minus? if drop ( 1 mystate ! ) else dup dpoint? if append 2 mystate ! else drop then then then ; : (2) ( c -- ) dup digit? if append ( 2 mystate ! ) else drop then ; : ( char state -- ) case 0 of (0) endof 1 of (1) endof 2 of (2) endof default: endcase ; : getafix reset 0 mystate ! begin key dup emit dup $0D <> \ exit on CR while mystate @ repeat drop \ CR cr show cr ;