6 * Demonstrate the use of goto, call and return. This machine expects either a
7 * lower case char or a digit as a command then a space followed by the command
8 * arg. If the command is a char, then the arg must be an a string of chars.
9 * If the command is a digit, then the arg must be a string of digits. This
10 * choice is determined by action code, rather than though transition
21 # A reference to a state in an unused action caused a segfault in 5.8. */
22 action unusedAction { fentry(garble_line); }
24 action err_garbling_line { prints "error: garbling line\n"; }
25 action goto_main { fgoto main; }
26 action recovery_failed { prints "error: failed to recover\n"; }
28 # Error machine, consumes to end of
29 # line, then starts the main line over.
30 garble_line := ( (any-'\n')*'\n')
35 action hold_and_return {fhold; fret;}
37 # Look for a string of alphas or of digits,
38 # on anything else, hold the character and return.
39 alp_comm := alpha+ $!hold_and_return;
40 dig_comm := digit+ $!hold_and_return;
42 # Choose which to machine to call into based on the command.
50 # Specifies command string. Note that the arg is left out.
52 [a-z0-9] @{comm = fc;} ' ' @comm_arg '\n'
53 ) @{prints "correct command\n";};
55 # Any number of commands. If there is an
56 # error anywhere, garble the line.
57 main := command* $!{fhold;fgoto garble_line;};
64 "*234234()0909 092 -234aslkf09`1 11\n"
109 error: failed to recover
112 error: failed to recover