s = ws! (Def+/ws) ws! Def = Id "(" (Id+/comma) "->" (Id+/comma) ")" "=" Exprs /ws Exprs = Exprs:: Decl */ ws ws! ((Expr +/ ws) +/ semicolons) Decl = Id ^"::" ShipName /ws Expr = "{" Exprs "}" /ws | (Literal|Port) ^"-->" Ports /ws | (Literal|Port) ^"+->" Ports /ws | (Literal|Port) ws! ^"-[" Int "]->" ws! Ports | (Literal|Port) ^"-[*]->" Ports /ws | ^"while" Cond Expr /ws // | "if" "then" "else" CondOp = ^"==" | ^"!=" | ^">" | ^">=" | ^"<" | ^"<=" Cond = Cond:: Port CondOp Int /ws Ports = ";":: Port +/ semicolon > ",":: Port +/ comma Port = "Port":: Id | "Port":: Id "." Id Literal = Int | ^"{" Int +/ comma "}" /ws Int = [\-0-9]++ ShipName = "":: [A-Z] [a-zA-Z0-9_]* Id = "":: [a-z] [a-zA-Z0-9_]* Comment = "//" (~eol)* eol! | "/*" (any* &~ (any*! "*/" any*!)) "*/" ws = (wsc | Comment)* -> ~wsc eol = [\r\n] wsc = [\r\n ] | \{ | \} comma = ws! "," ws! semicolon = ws! ";" ws! semicolons = ws! ";;" ws! any = ~[]