Scid  4.6.5
tokens.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // FILE: tokens.h
4 // Tokens used for scanning PGN.
5 //
6 // Part of: Scid (Shane's Chess Information Database)
7 // Version: 3.4
8 //
9 // Notice: Copyright (c) 1999-2001 Shane Hudson. All rights reserved.
10 //
11 // Author: Shane Hudson (sgh@users.sourceforge.net)
12 //
13 ///////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef SCID_TOKENS_H
17 #define SCID_TOKENS_H
18 
19 //
20 // TOKENS used by PGN scanner
21 //
22 
23 typedef uint tokenT;
24 
25 #define MAX_TOKEN 58;
26 
27 const tokenT
28  TOKEN_EndOfInput = 0, // No more characters to read from input source
29  TOKEN_Invalid = 1, // Unknown token
30  TOKEN_MoveNum = 3, // Move Number. e.g. "1." or "2..."
31  TOKEN_Ignore = 4; // Anything ignored, like "e.p."
32 
33 const tokenT
34  TOKEN_Move_Pawn = 5, // Excludes Promotions
35  TOKEN_Move_Promote = 6, // Promotions
36  TOKEN_Move_Piece = 7, // Includes ambiguous moves and captures
40 
41 inline bool
43 {
44  return (token >= TOKEN_Move_Pawn && token <= TOKEN_Move_Null);
45 }
46 
47 inline bool
49 {
50  return (token == TOKEN_Move_Pawn || token == TOKEN_Move_Promote);
51 }
52 
53 // Tags: currently only TOKEN_Tag. Maybe eventually have TOKEN_Tag_Event, etc.
54 const tokenT
55  TOKEN_Tag = 20,
57 #define TOKEN_isTag(x) ((x) == TOKEN_Tag)
58 
59 // Results
60 const tokenT
61  TOKEN_Result_White = 41, // White wins
62  TOKEN_Result_Black = 42, // Black wins
63  TOKEN_Result_Draw = 43, // Draw
64  TOKEN_Result_Star = 44; // Incomplete/unknown ("*")
65 #define TOKEN_isResult(x) (((x) >= 41) && ((x) <= 44))
66 
67 // Comments, Variations
68 const tokenT
69  TOKEN_Nag = 51, // $xxx example: $12
70  TOKEN_Suffix = 52, // !, ?, !!, ??, !?, ?!
71  TOKEN_Check = 53, // "+"
72  TOKEN_Mate = 54, // "#"
73  TOKEN_Comment = 55, // { .... }
74  TOKEN_LineComment = 56, // "%" or ";" until end of line
75  TOKEN_VarStart = 57, // "(" ....
76  TOKEN_VarEnd = 58, // .... ")"
77  TOKEN_CommentEnd = 59; // "}" outside of comment, should not happen
78 
79 #endif // SCID_TOKENS_H
80 
81 ///////////////////////////////////////////////////////////////////////////
82 // EOF: tokens.h
83 ///////////////////////////////////////////////////////////////////////////
const tokenT TOKEN_MoveNum
Definition: tokens.h:30
const tokenT TOKEN_Result_White
Definition: tokens.h:61
const tokenT TOKEN_Move_Pawn
Definition: tokens.h:34
const tokenT TOKEN_Suffix
Definition: tokens.h:70
const tokenT TOKEN_Invalid
Definition: tokens.h:29
const tokenT TOKEN_CommentEnd
Definition: tokens.h:77
const tokenT TOKEN_VarStart
Definition: tokens.h:75
const tokenT TOKEN_Move_Promote
Definition: tokens.h:35
const tokenT TOKEN_Result_Star
Definition: tokens.h:64
const tokenT TOKEN_VarEnd
Definition: tokens.h:76
const tokenT TOKEN_Nag
Definition: tokens.h:69
const tokenT TOKEN_Ignore
Definition: tokens.h:31
bool TOKEN_isMove(tokenT token)
Definition: tokens.h:42
const tokenT TOKEN_EndOfInput
Definition: tokens.h:28
const tokenT TOKEN_Move_Null
Definition: tokens.h:39
const tokenT TOKEN_Move_Castle_King
Definition: tokens.h:37
uint32_t uint
Definition: common.h:99
uint tokenT
Definition: tokens.h:23
const tokenT TOKEN_Move_Piece
Definition: tokens.h:36
const tokenT TOKEN_Result_Draw
Definition: tokens.h:63
const tokenT TOKEN_Comment
Definition: tokens.h:73
const tokenT TOKEN_LineComment
Definition: tokens.h:74
const tokenT TOKEN_Tag
Definition: tokens.h:55
const tokenT TOKEN_TagEnd
Definition: tokens.h:56
const tokenT TOKEN_Check
Definition: tokens.h:71
const tokenT TOKEN_Result_Black
Definition: tokens.h:62
const tokenT TOKEN_Move_Castle_Queen
Definition: tokens.h:38
const tokenT TOKEN_Mate
Definition: tokens.h:72
bool TOKEN_isPawnMove(tokenT token)
Definition: tokens.h:48