Marina/MarinaTest.java: a few hacks to get the silicon working
[fleet.git] / contrib / 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)     ^"+->"              Ports /ws
15      | (Literal|Port) ws! ^"-[" Int "]->" ws! Ports
16      | (Literal|Port)     ^"-[*]->"           Ports /ws
17      | ^"while" Cond Expr /ws
18 //   | "if" "then" "else"
19
20 CondOp = ^"==" | ^"!=" | ^">" | ^">=" | ^"<" | ^"<="
21 Cond   = Cond:: Port CondOp Int /ws
22
23 Ports    = ";":: Port +/ semicolon
24          > ",":: Port +/ comma
25 Port     = "Port":: Id
26          | "Port":: Id "." Id
27
28 Literal  = Int | ^"{" Int +/ comma "}" /ws
29 Int      = [\-0-9]++
30 ShipName = "":: [A-Z] [a-zA-Z0-9_]*
31 Id       = "":: [a-z] [a-zA-Z0-9_]*
32
33 Comment    = "//" (~eol)* eol!
34            | "/*" (any* &~ (any*! "*/" any*!)) "*/"
35 ws         = (wsc | Comment)* -> ~wsc
36 eol        = [\r\n]
37 wsc        = [\r\n ] | \{ | \}
38 comma      = ws! "," ws!
39 semicolon  = ws! ";" ws!
40 semicolons = ws! ";;" ws!
41 any        = ~[]