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
19 | ^"literal" Literal RequeueCount ";" /ws
20 | RepeatCount Commands RequeueCount ^";" /ws
21 RepeatCount = "" | ^"[*]" | "[" int "]"
23 | "," "requeue" (^"forever" | int ws "times") /ws
25 Commands:: = Command +/ (ws "," ws)
33 | ^"sendto" Destination /ws
34 | ^"notify" Destination /ws
35 | ^"notifyLast" Destination /ws
38 | ShipType "." PortName ^"[" Constants "]"
40 | "{" CodeBagBody "}" /ws
42 Pump:: = ShipName "." PortName
43 Destination:: = ShipName "." PortName
44 Constants:: = Constant +/ ","
45 Constant:: = [a-zA-Z0-9=_\-]++
47 CodeBagName = UpcaseWord
49 ShipName = DowncaseWord
50 PortName = DowncaseWord
51 Word = UpcaseWord | DowncaseWord
52 UpcaseWord = Name:: [A-Z] ("":: [A-Za-z0-9_]**)
53 DowncaseWord = Name:: [a-z] ("":: [A-Za-z0-9_]**)
54 int:: = (^"-"|^"") (^"0x"|^"0b"|^"") (digits:: [0-9]++)
60 Comment! = "//" ~[\n\r]* [\r\n]
63 // the following extensions are not part of the official FLEET syntax
65 Directive = ^"#memory" "{" (Memory:: int +/ (ws! "," ws!)) "}" /ws
66 | ^"#import" [A-Za-z_.]++ /ws
67 | ^"#include" ws! "\"" ~[\"]+ "\""
68 | ^"#ship" ShipName ":" ("":: [0-9A-Za-z_.]++) /ws