// The FLEET Assembly Language Grammar // As specified in document 2005-ucies06 // comments are included where the grammar had to go beyond the strict // "letter of the law" in ies06 // Note that this is the *entire, complete* formal specification of // the grammar. An equivalent lex+yacc grammar and support code would // be several times as long. Comment = "//" ~[\n]* "\n" | "/*" ~[\n]* "*/" w = [\r\n ]* ws = (w | Comment)* -> ~[\r\n ] s = !ws Program !ws Program = CodeBag:: statements:(Statement +/ ws) Statement = Move !((ws ";")?) | CodeBag | ^"#define" Port Port /ws Move = Source ^"->" Destination /ws | Source ^"->*" Destination /ws | Port ^":=" Source /ws Destination = Port +/ (!ws "," !ws) Source = Port | CodeBag CodeBag = CodeBag:: name:(name !ws ":" !ws)? "{" !ws statements:(Statement +/ ws) !ws "}" (!ws ";")? Port = Port:: shipname ("." portname)* shipname = ShipName:: name index? portname = PortName:: name index? name = [A-Za-z0-9\[\]\.]** index = "[" [0-9]+ "]" | [0-9]+