-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpgn-bnf.txt
More file actions
38 lines (34 loc) · 2.46 KB
/
Copy pathpgn-bnf.txt
File metadata and controls
38 lines (34 loc) · 2.46 KB
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
<game> ::= {<space-comment>* <header>}* {<space-comment>* <board-fen>}* <space-comment>* <game-tree>
<header> ::= '[' <header-key> <whitespace>+ '"' <header-value> '"]'
<header-key> ::= 'Size' | 'Promotion' | 'Date' | 'Round' | 'White' | 'Black' | 'Result' | any string not containing whitespace or '"'
<header-value> ::= any string not containing '"'
<board-fen> ::= '[' <fen-string> ':' <line> ':' <time> ':' {'w' | 'b'} ']'
<fen-string> ::= any string not containing ':' or ']' ;to be parsed separately
<game-tree> ::= {'(' <space-comment>* <action> <space-comment>* <game-tree>')' <space-comment>*}* [<action> <space-comment>* <game-tree> <space-comment>*] | <outcome>
<action> ::= <turn-serial> <space-comment>* <move> {<space-comment>+ <move>}* <space-comment>*
<turn-serial> ::= <number> ['w' | 'b'] '.' | '/'
<space-comment> ::= <whitespace> | <comment>
<comment> ::= '{' <comment-text> '}' <whitespace>*
<comment-text> ::= any string not containing '{' or '}'
<move> ::= <physical-move> | <superphysical-move>
<physical-move> ::= [<absolute-board>] ([<piece-name>] [<file>] [<rank>] ['x'] <file> <rank> ['=' <promote-to>] | 'O-O' | 'O-O-O') [<check-symbol>] [<evaluation-symbol>]
<superphysical-move> ::= [<absolute-board>] [<piece-name>] [<file>] [<rank>] (<jump-indicator> ['x'] | [<jump-indicator>] ['x'] <to-board>) <file> <rank> ['=' <promote-to>] [<check-symbol>] [<present-moved-symbol>] [<evaluation-symbol>] <timeline-comment>*
<to-board> ::= <absote-board> | <relative-board>
<absolute-board> ::= '(' (['L'] <line> | [['L'] <line>] 'T' <time>) ')'
<relative-board> ::= '$(' (['L'] <difference> | [['L'] <difference>] 'T' <difference>) ')'
<piece-name> ::= 'P' | 'W' | 'K' | 'C' | 'Q' | 'Y' | 'S' | 'N' | 'R' | 'B' | 'U' | 'D'
<promote-to> ::= a piece symbol enabled by the Promotions header
<jump-indicator> ::= '>' | '>>'
<difference> ::= '=' | '+' <positive-number> | '-' <positive-number>
<file> ::= 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h'
<rank> ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8'
<check-symbol> ::= '+' | '#' | '*'
<evaluation-symbol> ::= '!!' | '!' | '??' | '?' | '!? ' | '?!'
<present-moved-symbol> ::= '~'
<timeline-comment> ::= <whitespace> '(' {'>L' <line> | '~T' <time>} ')'
<line> ::= ['+' | '-'] <natural-number>
<time> ::= <natural-number>
<natural-number> ::= '0' | <positive-number>
<positive-number> ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | ...
<whitespace> ::= {' ' | '\t' | '\n' | '\r'}+
<outcome> ::= '1-0' | '0-1' | '1/2-1/2'