1 // The FLEET Assembly Language Grammar [26-Aug-2007]
3 // Note that this is the *entire, complete* formal specification of
4 // the grammar. An equivalent lex+yacc grammar and support code would
5 // be several times as long.
8 Program:: = Directives CodeBagBody /ws
9 Directives:: = Directive */ ws
10 CodeBagBody:: = (Fiber | CodeBagDef) */ ws
11 CodeBagDef:: = CodeBagName ":" "{" CodeBagBody "}" /ws
12 Fiber:: = Pump ":" Instructions /ws
14 Instructions:: = Instruction +/ ws
15 Instruction = ^"unclog" ";" /ws
20 | ^"literal" Literal RequeueCount ";" /ws
21 | RepeatCount Commands RequeueCount ^";" /ws
22 RepeatCount = "" | ^"[*]" | "[" int "]"
24 | "," "requeue" (^"forever" | int ws "times") /ws
26 Commands:: = Command +/ (ws "," ws)
34 | ^"sendto" Destination /ws
35 | ^"notify" Destination /ws
36 | ^"notifyLast" Destination /ws
39 | ShipType "." PortName ^"[" Constants "]"
41 | "{" CodeBagBody "}" /ws
43 Pump:: = ShipName "." PortName
44 Destination:: = ShipName "." PortName
45 Constants:: = Constant +/ ","
46 Constant:: = [a-zA-Z0-9=_\-]++
48 CodeBagName = UpcaseWord
50 ShipName = DowncaseWord
51 PortName = DowncaseWord
52 Word = UpcaseWord | DowncaseWord
53 UpcaseWord = Name:: [A-Z] ("":: [A-Za-z0-9_]**)
54 DowncaseWord = Name:: [a-z] ("":: [A-Za-z0-9_]**)
55 int:: = (^"-"|^"") (^"0x"|^"0b"|^"") (digits:: [0-9]++)
61 Comment! = "//" ~[\n\r]* [\r\n]
64 // the following extensions are not part of the official FLEET syntax
66 Directive = ^"#memory" "{" (Memory:: int +/ (ws! "," ws!)) "}" /ws
67 | ^"#import" [A-Za-z_.]++ /ws
68 | ^"#include" ws! "\"" ~[\"]+ "\""
69 | ^"#ship" ShipName ":" ("":: [0-9A-Za-z_.]++) /ws