1 // The FLEET Assembly Language Grammar
4 // Note that this is the *entire, complete* formal specification of
5 // the grammar. An equivalent lex+yacc grammar and support code would
6 // be several times as long.
8 Comment = "//" ~[\n\r]* [\r\n]!
10 ws = ([\r\n ] | Comment)* -> ~[\r\n ]
13 Program = Program:: Directive+/ws
14 | Program:: (Directive+/ws) ws! CodeBagBody
16 Statement = Fiber:: Source ":" (Instruction +/ ws) /ws
17 | Literal:: int ":" "sendto" Port ";" /ws
18 | CodeBagDescriptor:: CodeBag ":" "sendto" Port ";" /ws
19 | NamedCodeBag:: name ":" "{" CodeBagBody "}" /ws
21 CountField = Brack:: "[" int "]"
25 Instruction = Instruction::
27 (Command +/ (ws! "," ws!) ws! ";"!)
33 | Take:: ("take"|"receive")
34 | SendTo:: "sendto" ws! Port
36 | Ack:: "notify" ws! Port
41 Port = Port:: shipname "." portname
44 CodeBagBody = Statement +/ ws
45 CodeBag = CodeBagRef:: CodeBagName
46 | AnonymousCodeBag:: "{" CodeBagBody "}" /ws
51 name = Name:: [A-Za-z] [A-Za-z0-9\[\]_]**
52 index = "[" [0-9]+ "]" | [0-9]+
54 ShipSpecific = ShipSpecific:: "\"" ~[\"]++ "\""
56 // the following are not part of the official FLEET syntax and are
57 // specific to Adam's interpreter.
59 Directive = Memory:: "#memory" "{" (int +/ (ws! "," ws!)) "}" /ws
60 | Import:: "#import" [A-Za-z_.]++ /ws
61 | Include:: "#include" ("\"" (~[\"])+ "\"") /ws
62 | Ship:: "#ship" shipname ":" [0-9A-Za-z_.]++ /ws
63 | Expect:: "#expect" int /ws