fmexec


Name

fmexec -- execute a machine on an input string

Synopsis

fmexec [-d] fa string

fmexec [-d] string <fm


Description

fmexec tests the word string for membership in the language of the machine fm. If string is accepted, fmexec returns 1 and writes accepted on its standard error; otherwise it returns 0 and writes not accepted on its standard error. fmexec can execute both deterministic and nondeterministic machines.

The -d option causes fmexec to print each instruction that it executes for each character of string that is processed. In the case of nondeterministic machines, fmexec will print the set of instructions that are executed for each character of string.

fm must conform to the Grail format for machines. string should probably be protected from the shell by double quotes.


Examples

% cat nfm1
(START) |- 1
1 a 2
1 a 3
2 b 2
3 b 3
2 c 4
3 c 5
4 d 4
5 d 5
4 -| (FINAL)
5 -| (FINAL)

% fmexec nfm1 "abc"
accepted

% fmexec nfm1 "abbbbbbbbbbcdddddddddddd"
accepted

% fmexec nfm1 "x"
not accepted

% fmexec -d "abbcd" <nfm1
on a take instructions
1 a 2 
1 a 3
on b take instructions
2 b 2 
3 b 3
on b take instructions
2 b 2 
3 b 3 
on c take instructions
2 c 4 
3 c 5 
on d take instructions
4 d 4 
5 d 5
terminate on final states 4 5 

accepted
 

Authors

Darrell Raymond and Derick Wood, the Grail project

See also

fm(5), fmenum(1)