Generic (but simplified) FSA implementation, with actions and simple combinators
  • OCaml 97.2%
  • Standard ML 2.8%
Find a file
2017-07-10 22:22:34 +02:00
.gitignore Ignored generated files 2017-07-10 21:36:33 +02:00
.merlin Initial commit 2017-07-06 23:20:58 +02:00
_tags Tags 2017-07-07 15:42:47 +02:00
action.ml Implemented Graphviz export (fixed #5) 2017-07-10 21:09:22 +02:00
automata.ml Split the big main file into 3 tools 2017-07-10 21:36:10 +02:00
cashregister.aut Made the last newline token insignificant 2017-07-10 22:14:49 +02:00
cashregister.png Cash register example 2017-07-10 21:26:21 +02:00
combinator_lexer.mll Implemented a parser for combinators 2017-07-09 23:53:04 +02:00
combinator_parser.mly Implemented a parser for combinators 2017-07-09 23:53:04 +02:00
combinators.ml Implemented a parser for combinators 2017-07-09 23:53:04 +02:00
combinators.mli Implemented a parser for combinators 2017-07-09 23:53:04 +02:00
compiler.ml Style 2017-07-10 19:09:28 +02:00
compiler.mli Implemented an FSA compiler 2017-07-09 19:47:19 +02:00
demo.aut Fixed the demo script 2017-07-09 21:24:47 +02:00
dot.ml Split the big main file into 3 tools 2017-07-10 21:36:10 +02:00
fsa.ml Implemented Graphviz export (fixed #5) 2017-07-10 21:09:22 +02:00
fsa.mli Implemented Graphviz export (fixed #5) 2017-07-10 21:09:22 +02:00
grammar.ml Fixed the reduction issue in the parser 2017-07-09 17:52:02 +02:00
lexer.mll Fixed the string lexer 2017-07-09 20:17:03 +02:00
parser.mly Made the last newline token insignificant 2017-07-10 22:14:49 +02:00
README.md README.md: added the Tools and Building sections 2017-07-10 22:22:16 +02:00
run.ml Split the big main file into 3 tools 2017-07-10 21:36:10 +02:00
server.ml Oops 2017-07-10 22:22:34 +02:00
symbol.ml Implemented Graphviz export (fixed #5) 2017-07-10 21:09:22 +02:00
udp.ml Implemented server commands 2017-07-10 01:47:22 +02:00
udp.mli Implemented server commands 2017-07-10 01:47:22 +02:00

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 < b will produce b's actions when a doesn't
  • a || b will produce (at each step) actions from a and b, in this order

Tools

  • server.ml is a UDP server (for pranks, etc.)
  • run.ml is a combinator tester
  • dot.ml converts 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:

Cash register graph