Generic (but simplified) FSA implementation, with actions and simple combinators
- OCaml 97.2%
- Standard ML 2.8%
| .gitignore | ||
| .merlin | ||
| _tags | ||
| action.ml | ||
| automata.ml | ||
| cashregister.aut | ||
| cashregister.png | ||
| combinator_lexer.mll | ||
| combinator_parser.mly | ||
| combinators.ml | ||
| combinators.mli | ||
| compiler.ml | ||
| compiler.mli | ||
| demo.aut | ||
| dot.ml | ||
| fsa.ml | ||
| fsa.mli | ||
| grammar.ml | ||
| lexer.mll | ||
| parser.mly | ||
| README.md | ||
| run.ml | ||
| server.ml | ||
| symbol.ml | ||
| udp.ml | ||
| udp.mli | ||
automata
This is a kind of generic FSA implementation. It was written to handle keystrokes, so there are no accepting states but each transition can trigger actions:
- printing constant strings in the terminal:
print "hi!" - broadcasting the same kind of strings in UDP:
bc 2000 "HELLO EVERYONE"
Combinators allow you prioritizing automata:
a < bwill produceb's actions whenadoesn'ta || bwill produce (at each step) actions fromaandb, in this order
Tools
server.mlis a UDP server (for pranks, etc.)run.mlis a combinator testerdot.mlconverts FSAs to graphs (see Examples below)
Building
opam install ocamlbuild menhir
ocamlbuild -lib unix -use-menhir dot.byte run.byte server.byte
Examples
A cash register simulator
Running
./dot.byte cashregister.aut |dot -Tpng >cashregister.png
... on this file
(* transition macros *)
digit='0'-'9'
(* action macros *)
T=broadcast 2000 "tick"
D=broadcast 2000 "ding"
(* 0 is the initial state *)
0: digit -> typing; T
typing: digit -> typing; T
'\n' -> 0; D
... yields:
