-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathabif-v0.02.ebnf
54 lines (45 loc) · 1.42 KB
/
abif-v0.02.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%import common.WS
%import common.NEWLINE
%import common.ESCAPED_STRING
%ignore WS
ASTERISK : "*"
EQUAL : "="
OPENSQ : "["
CLOSEDSQ : "]"
CLOSEDCURLY : "}"
COLON : ":"
HASHMARK : "#"
INTEGER : ( "0".."9" )+
OPENCURLY : "{"
SLASH : "/"
QUOTATION_MARK : "\""
QKEY : (OPENSQ | QUOTATION_MARK ) BKEY (CLOSEDSQ | QUOTATION_MARK)
BKEY : (("a".."z"|"A".."Z")+ | ESCAPED_STRING )
QVALUE : "\"" ("a".."z"|"A".."Z"|" "|"0".."9")+ "\""
?start: abiffile
?abiffile : ( comment | json_line | cand_line | voteline )+
// comment
comment : HASHMARK comment_string NEWLINE
comment_string : /[^\r\n]+/
// json_line - This is a subset of JSON that only allows for key/value pairs.
json_line : ( OPENCURLY [json_pair] CLOSEDCURLY ) comment?
json_pair : json_key ":" ( QVALUE | QKEY )
json_key: ( QKEY | BKEY )
// cand_line
cand_pair : cand_key ":" ( QVALUE | QKEY )
cand_key: ( QKEY | BKEY )
cand_line : ( EQUAL? cand_key cand_id_sep ( cand_square_quoted | cand_key ) ) comment?
cand_square_quoted : OPENSQ /[^\]]+/ CLOSEDSQ
cand_id_sep : COLON
// voteline
voteline : ballot_count count_sep cands_in_voteline comment?
ballot_count : INTEGER
?cands_in_voteline : ( cands_in_voteline cand_sep cand_voter_pref | cand_voter_pref )
cand_voter_pref : ( cand_id | cand_tok_rating )
cand_tok_rating : cand_id SLASH rating
cand_sep : ( eq | gt )
eq : ( "=" | "," )
gt : ">"
rating : ("0".."9")+
count_sep : ( COLON | ASTERISK )
cand_id : ( cand_key | cand_square_quoted )