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 ]
22 Directive = Memory:: "#memory" "{" (int +/ (ws! "," ws!)) "}" /ws
23 | Import:: "#import" [A-Za-z_.]++ /ws
24 | Ship:: "#ship" shipname ":" [A-Za-z_\.]++ /ws
27 Statement = Move ((ws ";")?)!
29 // | ^"#define" Port Port /ws
31 Move = Source ^"->" Destination /ws
32 | Source ^"->*" Destination /ws
33 | Port ^":=" Source /ws
35 Destination = Port +/ (ws! "," ws!)
38 CodeBagBody = CodeBag:: (Statement +/ ws)
39 CodeBag = NamedCodeBag::
40 name:(name ws! ":" ws!)?
42 ws! statements:(Statement +/ ws) ws!
46 //Port = Port:: shipname ("." portname)*
47 Port = Port:: shipname "." portname
49 shipname = ShipName:: name (index?)
50 portname = PortName:: name (index?)
51 name = [A-Za-z0-9\[\]]**
52 index = "[" [0-9]+ "]"