libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|
Go to the source code of this file.
Data Structures | |
struct | GblScannerCursor |
struct | GblScannerClass |
struct | GblScanner |
Macros | |
#define | GBL_SCANNER_DELIMETERS_DEFAULT |
Type System | |
Type UUID and cast operators | |
#define | GBL_SCANNER_TYPE |
#define | GBL_SCANNER(self) |
#define | GBL_SCANNER_CLASS(klass) |
#define | GBL_SCANNER_GET_CLASS(self) |
Scanning | |
Methods for scanning the next token | |
Peeking | |
Methods for peeking at the next token |
Typedefs | |
typedef GblEnum | GBL_SCANNER_FLAGS |
Enumerations | |
enum | GBL_SCANNER_FLAGS |
Functions | |
Lifetime Management | |
Methods for managing GblScanner creation/destruction | |
GblScanner * | GblScanner_create (const char *pStr, size_t len) |
GblScanner * | GblScanner_ref (GblScanner *pSelf) |
GblRefCount | GblScanner_unref (GblScanner *pSelf) |
GblScanner, generic text tokenizer and lexer.
The main operation is to set the delimeter pattern (regex, powered by the TinyCRegex submodule), and then use GblScanner_peekToken() (and friends) to "view" the upcoming token without actually advancing the stream or do GblScanner_scanToken() (and friends) to take the next token and advance the buffer.
This basically lets GblScanner operate with a one-token lookahead at all time. If you need to inspect more tokens than just that without modifying the buffer state, that's when you would use GblScanner_pushCursor() to save your state, then peek/scan, and when you need to back up and restore an old state, use GblScanner_popCursor().
The main two operations are peek and scan, with their results being immediately stored in the public GblStringView variables GblScanner::next and GblScanner::token respectively. The variations of peek/scan are simply using GblStringView to handle type conversions for you, like GblScanner_scanUint32() for example, scans into GblScanner::token and then calls GblStringView_toUint32() on the token for you automatically.
Definition in file gimbal_scanner.h.
#define GBL_SCANNER_TYPE |
Type UUID for GblScanner.
Definition at line 45 of file gimbal_scanner.h.
#define GBL_SCANNER | ( | self | ) |
Function-style cast for GblInstance.
Definition at line 46 of file gimbal_scanner.h.
#define GBL_SCANNER_CLASS | ( | klass | ) |
Function-style cast for GblClass.
Definition at line 47 of file gimbal_scanner.h.
#define GBL_SCANNER_GET_CLASS | ( | self | ) |
Get a GblScannerClass from GblInstance.
Definition at line 48 of file gimbal_scanner.h.
#define GBL_SCANNER_DELIMETERS_DEFAULT |
Default delimeters used with GblScanner for tokenizing the input stream.
Definition at line 52 of file gimbal_scanner.h.
typedef GblEnum GBL_SCANNER_FLAGS |
Definition at line 63 of file gimbal_scanner.h.
enum GBL_SCANNER_FLAGS |
Extensible enum of flags used for GblScanner::status.
Definition at line 63 of file gimbal_scanner.h.
GblScanner * GblScanner_create | ( | const char * | pStr, |
size_t | len | ||
) |
Creates and returns a new GblScanner, setting its input to the given string with optional length.
GblScanner * GblScanner_ref | ( | GblScanner * | pSelf | ) |
Acquires a reference to the given scanner, incrementing its reference count and returning its address.
GblRefCount GblScanner_unref | ( | GblScanner * | pSelf | ) |
Releases a reference to the given scanner, returning the remaining count, and destroying the scanner when it hits 0.