|
1 | | -letrun_stepxsym= |
2 | | -Fsa.stepSymbol.test x sym|> |
| 1 | +letcompiles= |
| 2 | +letcompile_automatonfn= |
| 3 | +let ch= open_in fnin |
| 4 | +let a, assignments=Lexing.from_channel ch|>Compiler.compilein |
| 5 | + close_in ch; |
| 6 | +Printf.printf"compiled %s:\n" fn; |
| 7 | +List.iter (fun (n,i) ->Printf.printf"%s -> %d\n" n i) assignments; |
| 8 | + ain |
| 9 | +letrecconvert=function |
| 10 | +|Combinators.Simplefn ->Combinators.Simple (compile_automaton fn) |
| 11 | +|Combinators.Sequencel ->Combinators.Sequence (List.map convert l) |
| 12 | +|Combinators.Unionl ->Combinators.Union (List.map convert l)in |
| 13 | +Lexing.from_string s|> |
| 14 | +Combinator_parser.topCombinator_lexer.top|> |
| 15 | + convert |
| 16 | + |
| 17 | +letrun_steptsym= |
| 18 | +Combinators.stepSymbol.test t sym|> |
3 | 19 | List.iterAction.run; |
4 | | -x |
| 20 | +t |
5 | 21 |
|
6 | 22 | let()= |
7 | | -ifArray.lengthSys.argv<>2||Sys.argv.(1)="--help"then ( |
8 | | -Printf.fprintf stderr"usage: %sinput_string\n"Sys.argv.(0); |
| 23 | +ifArray.lengthSys.argv<>3then ( |
| 24 | +Printf.fprintf stderr"usage: %sautomata input\n"Sys.argv.(0); |
9 | 25 | exit1 |
10 | 26 | ); |
11 | | -let lexbuf=Lexing.from_channel stdinin |
12 | | -let a, assignments=Compiler.compile lexbufin |
13 | | -List.iter (fun (n,i) ->Printf.printf"%s -> %d\n" n i) assignments; |
| 27 | +let t= compileSys.argv.(1)in |
14 | 28 | let steps= |
15 | | -let s=Sys.argv.(1)in |
| 29 | +let s=Sys.argv.(2)in |
16 | 30 | Array.init (String.length s) (funi -> s.[i])in |
17 | | -Array.fold_left run_stepa steps|> ignore |
| 31 | +Array.fold_left run_stept steps|> ignore |