#include <Tokenizer.hpp>
Public Types | |
| enum | TOKEN { TOKEN_EOF, TOKEN_EOL, TOKEN_SYMBOL, TOKEN_INTEGER, TOKEN_FLOAT, TOKEN_CHAR, TOKEN_IDENTIFIER, TOKEN_KEYWORD, TOKEN_STRING } |
Rodzaje tokenów. More... | |
Public Member Functions | |
| Tokenizer (const tchar *Input, size_t NumChars, uint Flags) | |
| Tworzy z dokumentu podanego przez łańcuch tchar*. | |
| Tokenizer (const tstring *Input, uint Flags) | |
| Tworzy z dokumentu podanego przez tstring. | |
| Tokenizer (Stream *Input, uint Flags) | |
| Tworzy z dokumentu wczytywanego z dowolnego strumienia. | |
| ~Tokenizer () | |
| void | CreateError () |
| Rzuca wyjątek z błędem parsowania. Domyślny komunikat. | |
| void | CreateError (const tstring &Msg) |
| Rzuca wyjątek z błędem parsowania. Własny komunikat. | |
Konfiguracja | |
| void | RegisterKeyword (uint Id, const tstring &Keyword) |
| void | RegisterKeywords (const tchar **Keywords, size_t KeywordCount) |
| Wczytuje całą listę słów kluczowych w postaci tablicy łańcuchów tchar*. | |
Funkcje podstawowe | |
| void | Next () |
| Odczytuje następny token. | |
| TOKEN | GetToken () |
| Zwraca typ tokena. | |
| size_t | GetCharNum () |
| size_t | GetRowNum () |
| size_t | GetColNum () |
| const tstring & | GetString () |
| Działa zawsze, ale zastosowanie głównie dla GetToken() == common::Tokenizer::TOKEN_IDENTIFIER lub common::Tokenizer::TOKEN_STRING. | |
| tchar | GetChar () |
| Tylko jeśli GetToken() == common::Tokenizer::TOKEN_CHAR lub common::Tokenizer::TOKEN_SYMBOL. | |
| uint | GetId () |
| Tylko jeśli GetToken() == common::Tokenizer::TOKEN_KEYWORD. | |
| bool | GetUint1 (uint1 *Out) |
| Tylko jeśli GetToken() == common::Tokenizer::TOKEN_INTEGER. | |
| bool | GetUint2 (uint2 *Out) |
| bool | GetUint4 (uint4 *Out) |
| bool | GetUint8 (uint8 *Out) |
| bool | GetInt1 (int1 *Out) |
| bool | GetInt2 (int2 *Out) |
| bool | GetInt4 (int4 *Out) |
| bool | GetInt8 (int8 *Out) |
| uint1 | MustGetUint1 () |
| uint2 | MustGetUint2 () |
| uint4 | MustGetUint4 () |
| uint8 | MustGetUint8 () |
| int1 | MustGetInt1 () |
| int2 | MustGetInt2 () |
| int4 | MustGetInt4 () |
| int8 | MustGetInt8 () |
| bool | GetFloat (float *Out) |
| bool | GetDouble (double *Out) |
| float | MustGetFloat () |
| double | MustGetDouble () |
Zapytania | |
| bool | QueryToken (TOKEN Token) |
| bool | QueryToken (TOKEN Token1, TOKEN Token2) |
| bool | QueryEOF () |
| bool | QueryEOL () |
| bool | QuerySymbol (tchar Symbol) |
| bool | QueryIdentifier (const tstring &Identifier) |
| bool | QueryKeyword (uint KeywordId) |
| bool | QueryKeyword (const tstring &Keyword) |
Asercje | |
| void | AssertToken (TOKEN Token) |
| Rzuca wyjątek z błędem parsowania, jeśli ostatnio sparsowany token nie jest podanego rodzaju. | |
| void | AssertToken (TOKEN Token1, TOKEN Token2) |
| Rzuca wyjątek z błędem parsowania, jeśli ostatnio sparsowany token nie jest jednego z dwóch podanych rodzajów. | |
| void | AssertEOF () |
| void | AssertEOL () |
| void | AssertSymbol (tchar Symbol) |
| void | AssertIdentifier (const tstring &Identifier) |
| void | AssertKeyword (uint KeywordId) |
| void | AssertKeyword (const tstring &Keyword) |
Static Public Member Functions | |
| static const tchar * | GetTokenName (TOKEN Token) |
| Zamienia typ tokena na jego czytelny dla użytkownika opis tekstowy, np. "Stała znakowa". | |
Static Public Attributes | |
| static const uint | FLAG_TOKEN_EOL = 0x01 |
| Koniec wiersza ' ' ma być uznawany za osobnego rodzaju token, nie za zwyczajny biały znak. | |
| static const uint | FLAG_MULTILINE_STRINGS = 0x02 |
| Łańcuch "" może się rozciągać na wiele wierszy zawierając w treści koniec wiersza. | |
Rodzaje tokenów.
Tworzy z dokumentu podanego przez łańcuch tchar*.
Tworzy z dokumentu podanego przez tstring.
Tworzy z dokumentu wczytywanego z dowolnego strumienia.
| common::Tokenizer::~Tokenizer | ( | ) |
| void common::Tokenizer::AssertEOF | ( | ) |
| void common::Tokenizer::AssertEOL | ( | ) |
| void common::Tokenizer::AssertIdentifier | ( | const tstring & | Identifier | ) |
| void common::Tokenizer::AssertKeyword | ( | const tstring & | Keyword | ) |
| void common::Tokenizer::AssertKeyword | ( | uint | KeywordId | ) |
| void common::Tokenizer::AssertSymbol | ( | tchar | Symbol | ) |
Rzuca wyjątek z błędem parsowania, jeśli ostatnio sparsowany token nie jest jednego z dwóch podanych rodzajów.
| void common::Tokenizer::AssertToken | ( | TOKEN | Token | ) |
Rzuca wyjątek z błędem parsowania, jeśli ostatnio sparsowany token nie jest podanego rodzaju.
| void common::Tokenizer::CreateError | ( | const tstring & | Msg | ) |
Rzuca wyjątek z błędem parsowania. Własny komunikat.
| void common::Tokenizer::CreateError | ( | ) |
Rzuca wyjątek z błędem parsowania. Domyślny komunikat.
| tchar common::Tokenizer::GetChar | ( | ) |
Tylko jeśli GetToken() == common::Tokenizer::TOKEN_CHAR lub common::Tokenizer::TOKEN_SYMBOL.
| size_t common::Tokenizer::GetCharNum | ( | ) |
| size_t common::Tokenizer::GetColNum | ( | ) |
| bool common::Tokenizer::GetDouble | ( | double * | Out | ) |
Tylko jeśli GetToken() == common::Tokenizer::TOKEN_INTEGER lub common::Tokenizer::TOKEN_FLOAT
| bool common::Tokenizer::GetFloat | ( | float * | Out | ) |
Tylko jeśli GetToken() == common::Tokenizer::TOKEN_INTEGER lub common::Tokenizer::TOKEN_FLOAT
| uint common::Tokenizer::GetId | ( | ) |
Tylko jeśli GetToken() == common::Tokenizer::TOKEN_KEYWORD.
| bool common::Tokenizer::GetInt1 | ( | int1 * | Out | ) |
| bool common::Tokenizer::GetInt2 | ( | int2 * | Out | ) |
| bool common::Tokenizer::GetInt4 | ( | int4 * | Out | ) |
| bool common::Tokenizer::GetInt8 | ( | int8 * | Out | ) |
| size_t common::Tokenizer::GetRowNum | ( | ) |
| const tstring& common::Tokenizer::GetString | ( | ) |
Działa zawsze, ale zastosowanie głównie dla GetToken() == common::Tokenizer::TOKEN_IDENTIFIER lub common::Tokenizer::TOKEN_STRING.
| TOKEN common::Tokenizer::GetToken | ( | ) |
Zwraca typ tokena.
Zamienia typ tokena na jego czytelny dla użytkownika opis tekstowy, np. "Stała znakowa".
| bool common::Tokenizer::GetUint1 | ( | uint1 * | Out | ) |
Tylko jeśli GetToken() == common::Tokenizer::TOKEN_INTEGER.
| bool common::Tokenizer::GetUint2 | ( | uint2 * | Out | ) |
| bool common::Tokenizer::GetUint4 | ( | uint4 * | Out | ) |
| bool common::Tokenizer::GetUint8 | ( | uint8 * | Out | ) |
| double common::Tokenizer::MustGetDouble | ( | ) |
| float common::Tokenizer::MustGetFloat | ( | ) |
| int1 common::Tokenizer::MustGetInt1 | ( | ) |
| int2 common::Tokenizer::MustGetInt2 | ( | ) |
| int4 common::Tokenizer::MustGetInt4 | ( | ) |
| int8 common::Tokenizer::MustGetInt8 | ( | ) |
| uint1 common::Tokenizer::MustGetUint1 | ( | ) |
| uint2 common::Tokenizer::MustGetUint2 | ( | ) |
| uint4 common::Tokenizer::MustGetUint4 | ( | ) |
| uint8 common::Tokenizer::MustGetUint8 | ( | ) |
| void common::Tokenizer::Next | ( | ) |
Odczytuje następny token.
| bool common::Tokenizer::QueryEOF | ( | ) |
| bool common::Tokenizer::QueryEOL | ( | ) |
| bool common::Tokenizer::QueryIdentifier | ( | const tstring & | Identifier | ) |
| bool common::Tokenizer::QueryKeyword | ( | const tstring & | Keyword | ) |
| bool common::Tokenizer::QueryKeyword | ( | uint | KeywordId | ) |
| bool common::Tokenizer::QuerySymbol | ( | tchar | Symbol | ) |
| bool common::Tokenizer::QueryToken | ( | TOKEN | Token | ) |
| void common::Tokenizer::RegisterKeywords | ( | const tchar ** | Keywords, | |
| size_t | KeywordCount | |||
| ) |
Wczytuje całą listę słów kluczowych w postaci tablicy łańcuchów tchar*.
Słowa kluczowe będą miały kolejne identyfikatory 0, 1, 2 itd.
const uint common::Tokenizer::FLAG_MULTILINE_STRINGS = 0x02 [static] |
Łańcuch "" może się rozciągać na wiele wierszy zawierając w treści koniec wiersza.
const uint common::Tokenizer::FLAG_TOKEN_EOL = 0x01 [static] |
Koniec wiersza '
' ma być uznawany za osobnego rodzaju token, nie za zwyczajny biały znak.
1.6.1