1 // The FLEET Assembly Language Grammar
2 // As specified in document 2005-ucies06
4 // comments are included where the grammar had to go beyond the strict
5 // "letter of the law" in ies06
7 // Note that this is the *entire, complete* formal specification of
8 // the grammar. An equivalent lex+yacc grammar and support code would
9 // be several times as long.
11 Comment = "//" ~[\n]* "\n"
15 ws = (w | Comment)* -> ~[\r\n ]
18 Program = CodeBag:: statements:(Statement +/ ws)
20 Statement = Move !((ws ";")?)
22 | ^"#define" Port Port /ws
24 Move = Source ^"->" Destination /ws
25 | Source ^"->*" Destination /ws
26 | Port ^":=" Source /ws
28 Destination = Port +/ (!ws "," !ws)
33 name:(name !ws ":" !ws)?
35 !ws statements:(Statement +/ ws) !ws
39 Port = Port:: shipname ("." portname)*
40 shipname = ShipName:: name index?
41 portname = PortName:: name index?
42 name = [A-Za-z0-9\[\]\.]**
43 index = "[" [0-9]+ "]"