added am10 inbox/outbox support
[fleet.git] / fleet.g
diff --git a/fleet.g b/fleet.g
index e18ee72..145ea0a 100644 (file)
--- a/fleet.g
+++ b/fleet.g
@@ -1,49 +1,50 @@
 // 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
+// Updated 05-Nov-2006
 
 // 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]* "*/"
-
-ws            = ([\r\n ] | Comment)* -> ~[\r\n ]
+w               = " " | "\n" | "\r"
+ws              =  w**
+                |  w** "//" (~[\n])*! "\n" ws!
 
-s              = ws! Program ws!
-Program        = Program::
+s               = ws! Program ws!
+Program         = Program::
                     (Directive ws!)*
                     CodeBagBody
 
-Statement      = Move ((ws ";")?)!
-               | NamedCodeBag:: name ":" "{" CodeBagBody "}" /ws
-
-Move           =                    Port     ^"->"              Destination  /ws
-               |                    Port    ^"+->"              Destination  /ws
-               |                    Port     ^"-(*)->"          Destination  /ws
-               |                    Port     ^"-(" int ")->"    Destination  /ws
-               |                    Port    ^"+-(" int ")->"    Destination  /ws
-               | LiteralMove::      int       "->"              Destination  /ws
-               | LiteralCountMove:: int       "-(" int ")->"    Destination  /ws
-               | CodeBagMove::      CodeBag   "->"              Port         /ws
-               | CodeBagMoveX::     Port      "<-"              CodeBag      /ws
-               |                    Port     ^"<-"              Port         /ws
-
-Destination    = "":: Port
-CodeBagBody    = CodeBag:: (Statement +/ ws)
-CodeBag        = CodeBagRef:: CodeBagName
-               | "{" CodeBagBody "}" /ws
-CodeBagName    = name
+Statement       = Instruction:: (Opcode ws!)? Source ws! Arrow ws! Port
+                | NamedCodeBag:: name ":" "{" CodeBagBody "}" /ws
+
+Opcode          = Triggered::   "triggered" OpcodeBody /ws
+                | UnTriggered::             OpcodeBody
+
+OpcodeBody      = ^"nop"      | ^"wait"     | ^"discard"     
+                | ^"nop+ack"  | ^"wait+ack" | ^"discard+ack" 
+                | ^"copy"     | ^"move"     | ^"accept"
+                | ^"copy+ack" | ^"move+ack" | ^"accept+ack"
+
+Arrow           = ^"->"
+                | ^"-[*]->"
+                | ^"-[" int "]->"
+
+Source         = Port
+               | CodeBag
+               | int
 
 Port           = Port::     shipname "." portname
-shipname       = ShipName:: name
-portname       = PortName:: name
-name           = Name:: [A-Za-z] [A-Za-z0-9\[\]]*
-index          = "[" [0-9]+ "]"
-               | [0-9]+
+               |           ^"()"
+
+CodeBagBody    = Statement +/ (ws (";" ws)?!)
+CodeBag        = CodeBagRef:: CodeBagName
+               | AnonymousCodeBag:: "{" CodeBagBody "}" /ws
+
+CodeBagName    = name &~ Opcode
+shipname       = name &~ Opcode
+portname       = name &~ Opcode
+name           = Name:: [A-Za-z] [A-Za-z0-9\[\]]**
+index          = "[" [0-9]+ "]" | [0-9]+
 int            = [\-0-9]++
 
 // the following are not part of the official FLEET syntax and are