checkpoint
[sbp.git] / tests / fleet.g
1 //
2 // The FLEET Assembly Language Grammar
3 // As specified in document 2005-ucies06
4 //
5
6 // comments are included where the grammar had to go beyond the strict
7 // "letter of the law" in ies06
8
9 //
10 // Note that this is the *entire, complete* formal specification of
11 // the grammar.  An equivalent lex+yacc grammar and support code would
12 // be several times as long.
13 //
14
15 Comment     !::= "//" ~[\n]* "\n"
16                | "/*" ~[\n]* "*/"
17
18 ws           ::= w**
19 w            ::= [\r\n ]
20                | Comment
21
22 Statement    ::= Move ";"?                             /ws
23                | "{" Statement* "}"
24                | Port "RENAMES" Port "ENDRENAME" ";"   /ws
25
26 Move         ::= Source      ^"->" Destination         /ws
27                | Destination ^":=" Source              /ws
28
29 Destination  ::= Port +/ (ws "," ws)
30 Source       ::= Port
31                | CodeBag
32
33 CodeBag      ::= CodeBagName? "{" Statement* "}" ";"?  /ws
34
35 // Note: this deviates from ies06
36 location     ::= shipname ("." portname)?
37 shipname     ::= name     index?
38 portname     ::= name     index?
39 name         ::= [A-Za-z] [A-Za-z0-9\[\]\.]*
40 index        ::= "[" [0-9]+ "]"
41                | [0-9]+
42
43
44 //
45 // The syntax should be rather self-explanatory; here are some of the
46 // grammatical operators you may not have seen before:
47 // 
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
54 //