update to new AM37 syntax
[fleet.git] / src / edu / berkeley / fleet / assembler / fleet.g
index dfee550..7b4ac5e 100644 (file)
@@ -1,4 +1,4 @@
-// The FLEET Assembly Language Grammar [26-Aug-2007]
+// The FLEET Assembly Language Grammar [22-Aug-2008]
 
 // Note that this is the *entire, complete* formal specification of
 // the grammar.  An equivalent lex+yacc grammar and support code would
@@ -9,45 +9,61 @@ Program::       = Directives CodeBagBody /ws
 Directives::    = Directive */ ws
 CodeBagBody::   = (Fiber | CodeBagDef) */ ws
 CodeBagDef::    = CodeBagName ":" "{" CodeBagBody "}" /ws
-Fiber::         = Pump        ":" Instructions        /ws
+Fiber::         = Dock        ":" Instructions        /ws
 
 Instructions::  = Instruction +/ ws
-Instruction     = ^"unclog"                          ";" /ws
-                | ^"clog"                            ";" /ws
-                | ^"kill"                            ";" /ws
-                | ^"kill"     int                    ";" /ws
-                | ^"literal"  Literal  RequeueCount  ";" /ws
-                | RepeatCount Commands RequeueCount ^";" /ws
-RepeatCount     = "" | ^"[*]" | "[" int "]"
-RequeueCount    = ""
-                | "," "requeue" (^"forever" | int ws "times") /ws
+Instruction     = Instruction:: (Tags:: Tag*) InstructionX
+                | ^"tail" ";" /ws
+Tag             = ^"[a]"  ws |  ^"[b]" ws
+                | ^"[!a]" ws | ^"[!b]" ws
+                | ^"[olc=0]" ws
+                | ^"[*]" ws
+                | ^"[Rq]" ws
+InstructionX    = (() | ^"[T]" ws) ^"nop"                                            ";" /ws
+                | (() | ^"[T]" ws)  (Commands:: Command +/ (ws "," ws))             ^";" /ws
+                | "olc=word"::      "set"  "olc" "=" "word"                          ";" /ws
+                | "ilc=word"::      "set"  "ilc" "=" "word"                          ";" /ws
+                | "olc=int"::       "set"  "olc" "=" int                             ";" /ws
+                | "ilc=int"::       "set"  "ilc" "=" int                             ";" /ws
+                |                   "set"  "ilc" "=" ^"*"                            ";" /ws
+                |                   "set"  "olc" ^"--"                               ";" /ws
+                |                   "set" ^"flags" "a" "=" Flags "," "b" "=" Flags   ";" /ws
+                |                   "set" ^"word"      "=" Literal                   ";" /ws
+                |              ^"shift" Literal                                      ";" /ws
 
-Commands::      = Command +/ (ws "," ws)
-Command         = ^"wait"
-                | ^"nop"
-                | ^"discard"
-                | ^"recieve"
-                | ^"take"
-                | ^"deliver"
-                | ^"send"
-                | ^"sendto"     Destination /ws
-                | ^"notify"     Destination /ws
-                | ^"notifyLast" Destination /ws
+Flags:: = (^"0") |  (^"1") | (^"a" |  ^"b" |  ^"c" | ^"!a" | ^"!b" | ^"!c") +/ (ws "|" ws)
+
+Command         = "recv token"::       "recv" ws "token"
+                |                     ^"recv"
+                | "recv"::             "recv" ws "word"
+                | "recv nothing"::     "recv" ws "nothing"
+                | "recv path"::        "recv" ws "path"
+                | "recv packet"::      "recv" ws "packet"
+                |                     ^"collect"
+                | "collect"::          "collect" ws "word"
+                | "collect nothing"::  "collect" ws "nothing"
+                | "collect path"::     "collect" ws "path"
+                | "collect packet"::   "collect" ws "packet"
+                |                     ^"deliver"
+                |                     ^"send"
+                | "send to"::          "send" "to"          Destination /ws
+                | "send token"::       "send" "token"       Destination /ws
+                | "send token to"::    "send" "token" "to"  Destination /ws
 
 Literal         = int
-                | ShipType "." PortName ^"[" Constants "]"
+                | ShipType "." DockName ^"[" Constants "]"
                 | CodeBagName
                 | "{" CodeBagBody "}" /ws
 
-Pump::          = ShipName "." PortName
-Destination::   = ShipName "." PortName
+Dock::          = ShipName "." DockName
+Destination::   = ShipName "." DockName ( ^"" | ^":i" | ^":0" | ^":1" )
 Constants::     = Constant +/ ","
 Constant::      = [a-zA-Z0-9=_\-]++
 
 CodeBagName     = UpcaseWord
 ShipType        = UpcaseWord
 ShipName        = DowncaseWord
-PortName        = DowncaseWord
+DockName        = DowncaseWord
 Word            = UpcaseWord | DowncaseWord
 UpcaseWord      = Name:: [A-Z]    ("":: [A-Za-z0-9_]**)
 DowncaseWord    = Name:: [a-z]    ("":: [A-Za-z0-9_]**)
@@ -60,11 +76,6 @@ wsx!            = ()
 Comment!        = "//" ~[\n\r]* [\r\n]
                 | "/*" ~[\n\r]* "*/"
 
-// the following extensions are not part of the official FLEET syntax
-
-Directive      = ^"#memory" "{" (Memory:: int +/ (ws! "," ws!)) "}" /ws
-               | ^"#import" [A-Za-z_.]++ /ws
-               | ^"#include" ws! "\"" ~[\"]+ "\""
-               | ^"#ship" ShipName ":" ("":: [0-9A-Za-z_.]++) /ws
+Directive      = ^"#ship" ShipName ":" ("":: [0-9A-Za-z_.]++) /ws
                | ^"#expect" int /ws
                | ^"#skip"