1 // The FLEET Assembly Language Grammar
2 // As specified in document 2005-ucies06
4 // comments are included where the grammar had to go beyond the strict
5 // "letter of the law" in ies06
7 // Note that this is the *entire, complete* formal specification of
8 // the grammar. An equivalent lex+yacc grammar and support code would
9 // be several times as long.
11 Comment ! = "//" ~[\n]* "\n"
18 Program = Statement+ /ws
20 Statement = Move ";"? /ws
22 | Port "RENAMES" Port "ENDRENAME" ";" /ws
23 // | "#define" Port Port /ws
25 Move = Source ^"->" Destination /ws
26 | Source ^"=>" Destination /ws
27 | Destination ^":=" Source /ws
29 Destination = Port +/ (ws "," ws)
33 CodeBag = CodeBagName? "{" Statement* "}" ";"? /ws
35 // Note: this deviates from ies06
36 Port = shipname ("." portname)*
37 shipname = name index?
38 portname = name index?
39 name = [A-Za-z] [A-Za-z0-9\[\]\.]*
40 index = "[" [0-9]+ "]"
45 // The syntax should be rather self-explanatory; here are some of the
46 // grammatical operators you may not have seen before:
48 // ^ marks the "key" token; this is used only after parsing
49 // / separated-by; all preceding elements are separated by the following element
50 // +/ one-or-more-with-separator; for example, "a"+/"," matches "a,a,a"
51 // */ zero-or-more-with-separator
52 // & intersection; a&b matches a string only if a matches it and b matches it
53 // &~ negated intersection; a&~b matches a string only if a matches it and b DOES NOT match it