The PGN scanner (lexer)
More...
#include <pgnscanner.h>
|
| int | LexerInput (char *buf, int maxSize) |
| | Provides more input to the parent class (general flex version)
|
| |
| std::size_t | LexerInput (char *buf, std::size_t maxSize) |
| | Provides more input to the parent class (Apple flex version)
|
| |
◆ PgnScanner() [1/3]
| hoover_chess_utils::pgn_reader::PgnScanner::PgnScanner |
( |
const char * |
inputData, |
|
|
std::size_t |
inputLen |
|
) |
| |
|
inlinenoexcept |
Constructor.
- Parameters
-
| [in] | inputData | Input data |
| [in] | inputLen | Input length |
◆ PgnScanner() [2/3]
| hoover_chess_utils::pgn_reader::PgnScanner::PgnScanner |
( |
const PgnScanner & |
| ) |
|
|
delete |
◆ PgnScanner() [3/3]
| hoover_chess_utils::pgn_reader::PgnScanner::PgnScanner |
( |
PgnScanner && |
| ) |
|
|
delete |
◆ asciiToUnsigned()
template<typename RetType , bool digitsOnly>
| RetType hoover_chess_utils::pgn_reader::PgnScanner::asciiToUnsigned |
( |
const char * |
str, |
|
|
const char * |
end, |
|
|
const char * |
tokenType |
|
) |
| |
|
inlineprivate |
Ascii to unsigned integer conversion.
- Template Parameters
-
| RetType | Unsigned integer type |
| digitsOnly | Whether the input is guaranteed to include only digits |
- Parameters
-
| [in] | str | Start of string to convert (inclusive) |
| [in] | end | End of string to convert (exclusive) |
| [in] | tokenType | Name of the token type, e.g., "NAG". Used for error reporting |
- Returns
- Unsigned integer
- Exceptions
-
| PgnError(PgnErrorCode::BAD_CHARACTER) | Integer overflow |
- Precondition
- When
digitsOnly = true, this function assumes that the string consists only of numbers.
In case digitsOnly is:
true: This function assumes that the string consists only of numbers. If this is not the case, this function results in undefined behavior.
false: This function returns early when the first non-digit character is encountered.
◆ charCoordToSq()
| static constexpr Square hoover_chess_utils::pgn_reader::PgnScanner::charCoordToSq |
( |
char |
colChar, |
|
|
char |
rowChar |
|
) |
| |
|
inlinestaticconstexprprivatenoexcept |
Translates character coordinates to a square.
- Parameters
-
| [in] | colChar | Column character (file), range: ['a', 'h'] |
| [in] | rowChar | Row character (rank), range: ['1', '8'] |
- Returns
- Corresponding square
◆ colCharToMask()
| static constexpr SquareSet hoover_chess_utils::pgn_reader::PgnScanner::colCharToMask |
( |
char |
colChar | ) |
|
|
inlinestaticconstexprprivatenoexcept |
Translates column coordinate (file) to a square set.
- Parameters
-
| [in] | colChar | Column character (file), range: ['a', 'h'] |
- Returns
- Corresponding set of squares
◆ getCurrentToken()
| PgnScannerToken hoover_chess_utils::pgn_reader::PgnScanner::getCurrentToken |
( |
| ) |
const |
|
inlinenoexcept |
Returns the previously scanned token.
- Returns
- Token
The token in textual format can be obtained with calls to YYText() and YYLeng() provided by the parent class.
Certain tokens are decoded by the scanner. The decoded information is obtained with a call to getTokenInfo().
- See also
- https://westes.github.io/flex/manual/Cxx.html
◆ getMovePieceScannerTokenForChar()
| static constexpr PgnScannerToken hoover_chess_utils::pgn_reader::PgnScanner::getMovePieceScannerTokenForChar |
( |
char |
c | ) |
|
|
inlinestaticconstexprprivatenoexcept |
◆ getPieceForChar()
| static constexpr Piece hoover_chess_utils::pgn_reader::PgnScanner::getPieceForChar |
( |
char |
c | ) |
|
|
inlinestaticconstexprprivatenoexcept |
◆ getTokenInfo()
Returns additional information on the token.
- Returns
- Additional inforation on the current token
◆ LexerInput() [1/2]
| int hoover_chess_utils::pgn_reader::PgnScanner::LexerInput |
( |
char * |
buf, |
|
|
int |
maxSize |
|
) |
| |
|
inlineprotected |
Provides more input to the parent class (general flex version)
- Parameters
-
| [in] | buf | Buffer for input data |
| [in] | maxSize | Maximum size of data to be provided |
- Returns
- Number of bytes provided
- See also
- https://westes.github.io/flex/manual/Cxx.html
◆ LexerInput() [2/2]
| std::size_t hoover_chess_utils::pgn_reader::PgnScanner::LexerInput |
( |
char * |
buf, |
|
|
std::size_t |
maxSize |
|
) |
| |
|
inlineprotected |
Provides more input to the parent class (Apple flex version)
- Parameters
-
| [in] | buf | Buffer for input data |
| [in] | maxSize | Maximum size of data to be provided |
- Returns
- Number of bytes provided
- See also
- https://westes.github.io/flex/manual/Cxx.html
◆ nextToken()
Scans input and returns the next token.
- Returns
- Token
- Exceptions
-
| PgnError(PgnErrorCode::BAD_CHARACTER) | Erroneous scanner input |
The token in textual format can be obtained with calls to YYText() and YYLeng() provided by the parent class.
Certain tokens are decoded by the scanner. The decoded information is obtained with a call to getTokenInfo().
- See also
- https://westes.github.io/flex/manual/Cxx.html
◆ nextTokenNoThrowOnErrorToken()
| PgnScannerToken hoover_chess_utils::pgn_reader::PgnScanner::nextTokenNoThrowOnErrorToken |
( |
| ) |
|
|
inline |
Scans input and returns the next token. On bad input, error token is returned instead of throwing an exception.
- Returns
- Token
This function is mainly intended for error recovery.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ rowCharToMask()
| static constexpr SquareSet hoover_chess_utils::pgn_reader::PgnScanner::rowCharToMask |
( |
char |
rowChar | ) |
|
|
inlinestaticconstexprprivatenoexcept |
Translates row coordinate (rank) to a square set.
- Parameters
-
| [in] | rowChar | Row character (rank), range: ['1', '8'] |
- Returns
- Corresponding set of squares
◆ scannerTokenToString()
| static constexpr const char * hoover_chess_utils::pgn_reader::PgnScanner::scannerTokenToString |
( |
PgnScannerToken |
token | ) |
|
|
inlinestaticconstexprnoexcept |
Returns a string for a scanner token.
- Parameters
-
| [in] | token | PGN scanner token |
- Returns
- Corresponding string
◆ setTokenInfo_ERROR()
| void hoover_chess_utils::pgn_reader::PgnScanner::setTokenInfo_ERROR |
( |
const char * |
errorMessage | ) |
|
|
inlineprivate |
◆ setTokenInfo_MOVENUM()
| void hoover_chess_utils::pgn_reader::PgnScanner::setTokenInfo_MOVENUM |
( |
const char * |
str, |
|
|
const char * |
end |
|
) |
| |
|
inlineprivate |
◆ setTokenInfo_NAG()
| void hoover_chess_utils::pgn_reader::PgnScanner::setTokenInfo_NAG |
( |
std::uint8_t |
nag | ) |
|
|
inlineprivate |
◆ setTokenInfo_PAWN_MOVE()
| void hoover_chess_utils::pgn_reader::PgnScanner::setTokenInfo_PAWN_MOVE |
( |
SquareSet |
srcMask, |
|
|
Square |
dstSq, |
|
|
Piece |
promoPiece |
|
) |
| |
|
inlineprivate |
◆ setTokenInfo_PIECE_MOVE()
| void hoover_chess_utils::pgn_reader::PgnScanner::setTokenInfo_PIECE_MOVE |
( |
SquareSet |
srcMask, |
|
|
bool |
capture, |
|
|
Square |
dstSq |
|
) |
| |
|
inlineprivate |
◆ setTokenInfo_RESULT()
| void hoover_chess_utils::pgn_reader::PgnScanner::setTokenInfo_RESULT |
( |
PgnResult |
result | ) |
|
|
inlineprivate |
◆ tokenizePieceMove()
| PgnScannerToken hoover_chess_utils::pgn_reader::PgnScanner::tokenizePieceMove |
( |
std::string_view |
str | ) |
|
|
inlineprivate |
◆ tokenizeUnusualPawnMove()
| PgnScannerToken hoover_chess_utils::pgn_reader::PgnScanner::tokenizeUnusualPawnMove |
( |
std::string_view |
str | ) |
|
|
inlineprivate |
◆ yylexex()
The generated lexer.
- Returns
- Token
◆ ctCharToMovePieceTable
| constexpr std::array<PgnScannerToken, 32> hoover_chess_utils::pgn_reader::PgnScanner::ctCharToMovePieceTable |
|
staticconstexprprivate |
◆ ctCharToPieceTable
| constexpr std::array<Piece, 32> hoover_chess_utils::pgn_reader::PgnScanner::ctCharToPieceTable |
|
staticconstexprprivate |
◆ m_curToken
◆ m_inputData
| const char* hoover_chess_utils::pgn_reader::PgnScanner::m_inputData |
|
private |
◆ m_inputLeft
| std::size_t hoover_chess_utils::pgn_reader::PgnScanner::m_inputLeft |
|
private |
◆ m_tokenInfo
The documentation for this class was generated from the following file: