checkpoint
[fleet.git] / src / edu / berkeley / fleet / f0 / f0.g
1 s               = ws! (Def+/ws) ws!
2
3 Def = Id "(" (Id+/comma) "->" (Id+/comma) ")" "=" Exprs /ws
4
5 Exprs =
6   Exprs:: Decl */ ws
7           ws!
8           ((Expr +/ ws) +/ semicolons)
9
10 Decl = Id   ^"::" ShipName  /ws
11
12 Expr = "{" Exprs "}"        /ws
13      | (Literal|Port)     ^"-->"              Ports /ws
14      | (Literal|Port) ws! ^"-[" Int "]->" ws! Ports
15      | (Literal|Port)     ^"-[*]->"           Ports /ws
16 //   | "if" "then" "else"
17 //   | "while"
18
19 Ports    = Port +/ comma
20 Port     = "Port":: Id
21          | "Port":: Id "." Id
22
23 Literal  = Int | ^"{" Int +/ comma "}" /ws
24 Int      = [\-0-9]++
25 ShipName = "":: [A-Z] [a-zA-Z0-9_]*
26 Id       = "":: [a-z] [a-zA-Z0-9_]*
27
28 Comment = "//" (~eol)* eol!
29            | "/*" (any* &~ (any*! "*/" any*!)) "*/"
30 ws      = (wsc | Comment)* -> ~wsc
31 eol     = [\r\n]
32 wsc     = [\r\n ] | \{ | \}
33 comma      = ws! "," ws!
34 semicolons = ws! ";;" ws!
35 any     = ~[]