Answers.Body: <p>I agree the spec is ambiguous.  This <a href="https://github.com/antlr/grammars-v4/blob/master/pgn/PGN.g4" rel="nofollow noreferrer">antlr grammar</a> uses your option b</p>
  
  <blockquote>
    <p>game termination markers should not be considered symbol tokens, but
    rather a distinct type of token which is separate from symbol tokens,
    and the author failed to indicate this</p>
  </blockquote>
  
  <p>In the grammar I find </p>
  
  <pre><code>SYMBOL
  : [a-zA-Z0-9] [a-zA-Z0-9_+#=:-]*
  ;
  </code></pre>
  
  <p>separate from termination</p>
  
  <pre><code>game_termination
   : WHITE_WINS
   | BLACK_WINS
   | DRAWN_GAME
   | ASTERISK
   ;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-23T13:41:58.870Z
Answers.LastActivityDate: 2020-01-23T13:41:58.870Z
Answers.UserDisplayName: Michael West
Answers.Body: <p>You are right, the text as written there isn't exactly correct.</p>
  
  <p>It also says that the marker is a symbol and lists <code>*</code> as one of the options, even though <code>*</code> is a token on its own and also cannot occur in a symbol.</p>
  
  <p>That said, the meaning is clear enough, 1/2-1/2 is a valid termination marker. How you solve this in your code is up to you. As it's hard to add <code>1/2-1/2</code> as a token on its own (would need lookahead to disambiguate it from symbol <code>1</code> et cetera), it's probably easiest to add '/' to the possible symbol characters, yes.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-23T14:09:11.237Z
Answers.Text: Thanks for raising the point about `*`.  I had gone ahead and coded `*` up as a token in its own right, but I think that you are correct to say that this is another error in the description of game termination markers.
Answers.UserDisplayName: direvus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-23T12:28:18.707Z
Answers.LastActivityDate: 2020-01-23T12:28:18.707Z
Answers.UserDisplayName: RemcoGerlich
Body: <p>The Portable Game Notation (PGN) specification appears to contradict itself regarding the valid characters that may appear in a symbol token.</p>
  
  <p>From [1], section 7, quote:</p>
  
  <blockquote>
    <p>A symbol token starts with a letter or digit character and is immediately followed by a sequence of zero or more symbol continuation characters. These continuation characters are letter characters ("A-Za-z"), digit characters ("0-9"), the underscore ("_"), the plus sign ("+"), the octothorpe sign ("#"), the equal sign ("="), the colon (":"), and the hyphen ("-") ...</p>
  </blockquote>
  
  <p>Or, to put it more concisely, a symbol token conforms to the regular expression <code>/^[A-Za-z0-9][A-Za-z0-9_+#=:-]*/</code>.  </p>
  
  <p>However, this definition explicitly precludes the game draw termination marker <code>1/2-1/2</code>.  Quoting again from [1], section 8.2.6:</p>
  
  <blockquote>
    <p>Each movetext section has exactly one game termination marker; the marker always occurs as the last element in the movetext. The game termination marker is a symbol that is one of the following four values: "1-0" (White wins), "0-1" (Black wins), "1/2-1/2" (drawn game), and "*" (game in progress, result unknown, or game abandoned).</p>
  </blockquote>
  
  <p>The string "1/2-1/2" very obviously does not meet the definition of a symbol token, so either:</p>
  
  <p>a) the solidus character ('/', 0x2f) should have been included in the definition of symbol continuation characters, but the author failed to do so, or;</p>
  
  <p>b) game termination markers should not be considered symbol tokens, but rather a distinct type of token which is separate from symbol tokens, and the author failed to indicate this, or;</p>
  
  <p>c) I have completely misunderstood the wording of the specification, and am an idiot.</p>
  
  <p>Somebody has screwed up here, and either it's me, or it's Steven J. Edwards.  Hopefully it's me.  Personally I think (a) is the most likely of the three but perhaps I've missed something.</p>
  
  <p>[1] <a href="http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm" rel="noreferrer">http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm</a></p>
  
Tags: <programming><pgn>
Title: Does the PGN specification mistakenly omit solidus (/) for symbol tokens?
ThreadText: # Does the PGN specification mistakenly omit solidus (/) for symbol tokens?
  
  (Asked by: username_0 on 2020-01-23)
  
  The Portable Game Notation (PGN) specification appears to contradict itself regarding the valid characters that may appear in a symbol token.
  
  From [1], section 7, quote:
  
  > A symbol token starts with a letter or digit character and is immediately followed by a sequence of zero or more symbol continuation characters. These continuation characters are letter characters ("A-Za-z"), digit characters ("0-9"), the underscore ("\_"), the plus sign ("+"), the octothorpe sign ("#"), the equal sign ("="), the colon (":"), and the hyphen ("-") ...
  
  Or, to put it more concisely, a symbol token conforms to the regular expression `/^[A-Za-z0-9][A-Za-z0-9_+#=:-]*/`.
  
  However, this definition explicitly precludes the game draw termination marker `1/2-1/2`. Quoting again from [1], section 8.2.6:
  
  > Each movetext section has exactly one game termination marker; the marker always occurs as the last element in the movetext. The game termination marker is a symbol that is one of the following four values: "1-0" (White wins), "0-1" (Black wins), "1/2-1/2" (drawn game), and "\*" (game in progress, result unknown, or game abandoned).
  
  The string "1/2-1/2" very obviously does not meet the definition of a symbol token, so either:
  
  a) the solidus character ('/', 0x2f) should have been included in the definition of symbol continuation characters, but the author failed to do so, or;
  
  b) game termination markers should not be considered symbol tokens, but rather a distinct type of token which is separate from symbol tokens, and the author failed to indicate this, or;
  
  c) I have completely misunderstood the wording of the specification, and am an idiot.
  
  Somebody has screwed up here, and either it's me, or it's Steven J. Edwards. Hopefully it's me. Personally I think (a) is the most likely of the three but perhaps I've missed something.
  
  [1] <http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm>
  
  **Tags:** programming, pgn
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-01-23. Score: 5 | Accepted answer
  
  You are right, the text as written there isn't exactly correct.
  
  It also says that the marker is a symbol and lists `*` as one of the options, even though `*` is a token on its own and also cannot occur in a symbol.
  
  That said, the meaning is clear enough, 1/2-1/2 is a valid termination marker. How you solve this in your code is up to you. As it's hard to add `1/2-1/2` as a token on its own (would need lookahead to disambiguate it from symbol `1` et cetera), it's probably easiest to add '/' to the possible symbol characters, yes.
  
  > **Comments:**
  > **username_0**: Thanks for raising the point about `*`.  I had gone ahead and coded `*` up as a token in its own right, but I think that you are correct to say that this is another error in the description of game termination markers.  
  
  ---
  
  ### Answer by username_1 on 2020-01-23. Score: 4
  
  I agree the spec is ambiguous. This [antlr grammar](https://github.com/antlr/grammars-v4/blob/master/pgn/PGN.g4) uses your option b
  
  > game termination markers should not be considered symbol tokens, but
  > rather a distinct type of token which is separate from symbol tokens,
  > and the author failed to indicate this
  
  In the grammar I find
  
  ```
  SYMBOL
  : [a-zA-Z0-9] [a-zA-Z0-9_+#=:-]*
  ;
  
  ```
  
  separate from termination
  
  ```
  game_termination
   : WHITE_WINS
   | BLACK_WINS
   | DRAWN_GAME
   | ASTERISK
   ;
  
  ```
  
  
  ---
  
  