update grammar, move to new version of SBP
[fleet.git] / src / edu / berkeley / fleet / assembler / fleet.g
index 8262356..f00912d 100644 (file)
@@ -5,15 +5,15 @@
 // the grammar.  An equivalent lex+yacc grammar and support code would
 // be several times as long.
 
-Comment        = "//" ~[\n\r]* [\r\n]!
-               | "/*" ~[\n\r]* "*/"
-ws             = ([\r\n ] | Comment)* -> ~[\r\n ]
+Comment        = "//" ~[\n\r]!* [\r\n]!
+               | "/*" ~[\n\r]!* "*/"
+ws             = ([\r\n ] | Comment)!* -> ~[\r\n ]
 
 s               = ws! Program ws!
 Program         = Program:: Directive+/ws
-                | Program:: (Directive+/ws) ws! CodeBagBody
+                | Program:: ("":: Directive+/ws) ws! CodeBagBody
 
-Statement       = Fiber::                  Source  ":" (Instruction +/ ws)     /ws
+Statement       = Fiber::                  Source  ":" ("":: Instruction +/ ws)     /ws
                 | Literal::                int     ":" "sendto" Port       ";" /ws
                 | ShipSpecificLiteral::    SSL     ":" "sendto" Port       ";" /ws
                 | CodeBagDescriptor::      CodeBag ":" "sendto" Port       ";" /ws
@@ -24,8 +24,8 @@ CountField      = Brack::     "[" int "]"
                 | BrackStar:: "[*]"
                 | ParenStar:: "(*)"
 Instruction     = Instruction::
-                        (CountField ws!)?
-                        (Command +/ (ws! "," ws!) ws! ";"!)
+                        ("":: (CountField ws!)?)
+                        ("":: Command +/ (ws! "," ws!) ws! ";"!)
 Command         = Nop::      "nop"
                 | Kill::     "kill"
                 | KillStar:: "kill*"
@@ -44,26 +44,26 @@ Port           = Port::     shipname "." portname
                | SubPort::  shipname "." portname "." portname
                |           ^"()"
 
-CodeBagBody    = Statement +/ ws
+CodeBagBody::  = Statement +/ ws
 CodeBag        = CodeBagRef:: CodeBagName
                | AnonymousCodeBag:: "{" CodeBagBody "}" /ws
 
 CodeBagName         = name
 shipname            = name
-shiptype            = Name:: [A-Z] [A-Za-z0-9\[\]_]**
-ShipSpecificLiteral = Name:: [A-Z] [A-Z0-9\[\]_]**
-portname            = Name:: [a-z] [A-Za-z0-9\[\]_]**
-name                = Name:: [A-Za-z] [A-Za-z0-9\[\]_]**
-index               = "[" [0-9]+ "]" | [0-9]+
-int                 = [\-0-9]++
+shiptype            = Name:: [A-Z]    ("":: [A-Za-z0-9\[\]_]**)
+ShipSpecificLiteral = Name:: [A-Z]    ("":: [A-Z0-9\[\]_]**)
+portname            = Name:: [a-z]    ("":: [A-Za-z0-9\[\]_]**)
+name                = Name:: [A-Za-z] ("":: [A-Za-z0-9\[\]_]**)
+index               = "[" ("":: [0-9]+) "]" | ("":: [0-9]+)
+int                 = "":: [\-0-9]++
 ShipSpecific        = ShipSpecific:: "\"" ~[\"]++ "\""
 
 // the following are not part of the official FLEET syntax and are
 // specific to Adam's interpreter.
 
-Directive      = Memory::  "#memory" "{" (int +/ (ws! "," ws!)) "}" /ws
+Directive      =           "#memory" "{" (Memory:: int +/ (ws! "," ws!)) "}" /ws
                | Import::  "#import" [A-Za-z_.]++ /ws
-               | Include:: "#include" ("\"" (~[\"])+ "\"") /ws
-               | Ship::    "#ship" shipname ":" [0-9A-Za-z_.]++ /ws
+               | Include:: "#include" ws! "\"" ~[\"]+ "\""
+               | Ship::    "#ship" shipname ":" ("":: [0-9A-Za-z_.]++) /ws
                | Expect::  "#expect" int /ws