add support for predicates to parser and interpreter
[fleet.git] / src / edu / berkeley / fleet / assembler / fleet.g
index 4964224..b674b3a 100644 (file)
@@ -11,10 +11,19 @@ CodeBagBody::   = (Fiber | CodeBagDef) */ ws
 CodeBagDef::    = CodeBagName ":" "{" CodeBagBody "}" /ws
 Fiber::         = Pump        ":" Instructions        /ws
 
+// FIXME: should not have predicates on clog/unclog/kill/massacre
 Instructions::  = Instruction +/ ws
-Instruction     = ^"unclog"                          ";" /ws
+Instruction::   = Predicate InstructionX
+Predicate       = "" | ^"[a]" ws | ^"[b]" ws | ^"[z]" ws
+InstructionX    = ^"unclog"                          ";" /ws
                 | ^"clog"                            ";" /ws
+                | ^"massacre"                        ";" /ws
                 | ^"kill"                            ";" /ws
+                |  "take" ^"loop" "counter"                            ";" /ws
+                | ^"load" (^"loop"|^"repeat") ws "counter"             ";" /ws
+                |  "load" (^"loop"|^"repeat") ws "counter" ^"with" int ";" /ws
+                | ^"decrement" "loop" "counter"                        ";" /ws
+                | ^"setflags" "a" "=" Flags "," "b" "=" Flags          ";" /ws
                 | ^"kill"     int                    ";" /ws
                 | ^"literal"  Literal  RequeueCount  ";" /ws
                 | RepeatCount Commands RequeueCount ^";" /ws
@@ -22,7 +31,18 @@ RepeatCount     = "" | ^"[*]" | "[" int "]"
 RequeueCount    = ""
                 | "," "requeue" (^"forever" | int ws "times") /ws
 
-// FIXME: ordering constraint on these
+Flags:: = Flag +/ (ws "|" ws)
+Flag =  ^"0"
+     |  ^"1"
+     |  ^"a"
+     |  ^"b"
+     |  ^"s"
+     |  ^"z"
+     | ^"!a"
+     | ^"!b"
+     | ^"!s"
+     | ^"!z"
+
 Commands::      = Command +/ (ws "," ws)
 Command         = ^"wait"
                 | ^"nop"