From: adam Date: Sun, 5 Mar 2006 07:00:07 +0000 (-0500) Subject: updated fleet.g X-Git-Tag: tag_for_25-Mar~280 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=0799e8b2438e6471cc7689d6a651508d5ab28135 updated fleet.g darcs-hash:20060305070007-5007d-c4b51970da306d97905c6e5ac1a7f04722c9bfb4.gz --- diff --git a/tests/fleet.g b/tests/fleet.g index 4677496..3f70ddf 100644 --- a/tests/fleet.g +++ b/tests/fleet.g @@ -8,47 +8,37 @@ // the grammar. An equivalent lex+yacc grammar and support code would // be several times as long. -Comment ! = "//" ~[\n]* "\n" +Comment = "//" ~[\n]* "\n" | "/*" ~[\n]* "*/" -ws = w** -w = [\r\n ] - | Comment +w = [\r\n ]* +ws = (w | Comment)* -> ~[\r\n ] -Program = Statement+ /ws +s = !ws Program !ws +Program = CodeBag:: statements:(Statement +/ ws) -Statement = Move ";"? /ws - | "{" Statement* "}" - | Port "RENAMES" Port "ENDRENAME" ";" /ws -// | "#define" Port Port /ws +Statement = Move !((ws ";")?) + | CodeBag + | ^"#define" Port Port /ws -Move = Source ^"->" Destination /ws - | Source ^"=>" Destination /ws - | Destination ^":=" Source /ws +Move = Source ^"->" Destination /ws + | Source ^"->*" Destination /ws + | Port ^":=" Source /ws -Destination = Port +/ (ws "," ws) +Destination = Port +/ (!ws "," !ws) Source = Port | CodeBag -CodeBag = CodeBagName? "{" Statement* "}" ";"? /ws - -// Note: this deviates from ies06 -Port = shipname ("." portname)* -shipname = name index? -portname = name index? -name = [A-Za-z] [A-Za-z0-9\[\]\.]* +CodeBag = CodeBag:: + name:(name !ws ":" !ws)? + "{" + !ws statements:(Statement +/ ws) !ws + "}" + (!ws ";")? + +Port = Port:: shipname ("." portname)* +shipname = ShipName:: name index? +portname = PortName:: name index? +name = [A-Za-z0-9\[\]\.]** index = "[" [0-9]+ "]" | [0-9]+ - - -// -// The syntax should be rather self-explanatory; here are some of the -// grammatical operators you may not have seen before: -// -// ^ marks the "key" token; this is used only after parsing -// / separated-by; all preceding elements are separated by the following element -// +/ one-or-more-with-separator; for example, "a"+/"," matches "a,a,a" -// */ zero-or-more-with-separator -// & intersection; a&b matches a string only if a matches it and b matches it -// &~ negated intersection; a&~b matches a string only if a matches it and b DOES NOT match it -//