ELinks 0.16.1.1
scanner Struct Reference

The struct scanner describes the current state of the scanner. More...

#include <scanner.h>

Collaboration diagram for scanner:

Data Fields

const char * string
 The very start of the scanned string, the position in the string where to scan next and the end of the string.
const char * position
const char * end
struct scanner_tokencurrent
 The current token and number of scanned tokens in the table.
int tokens
struct scanner_infoinfo
 The 'meta' scanner information.
int state
 Some state indicator only meaningful to the scanner internals.
struct scanner_token table [SCANNER_TOKENS]
 The table contain already scanned tokens.

(Note that these are not member symbols.)

void init_scanner (struct scanner *scanner, struct scanner_info *scanner_info, const char *string, const char *end)
 Initializes the scanner.
#define scanner_has_tokens(scanner)
#define check_scanner(scanner)
 This macro checks if the current scanner state is valid.
int map_scanner_string (struct scanner *scanner, const char *ident, const char *end, int base_type)
 Looks up the string from ident to end to in the scanners string mapping table.
#define check_next_scanner_token(scanner, token_type)
 Checks the type of the next token.
static struct scanner_tokenget_scanner_token (struct scanner *scanner)
 Access current and next token.
static struct scanner_tokenget_next_scanner_token (struct scanner *scanner)
 Do a scanning if we do not have also have access to next token.
#define skip_scanner_token(scanner)
 This should just make the code more understandable .
struct scanner_tokenskip_scanner_tokens (struct scanner *scanner, int skipto, int precedence)
 Removes tokens from the scanner until it meets a token of the given type.

Detailed Description

The struct scanner describes the current state of the scanner.

◆ check_next_scanner_token

#define check_next_scanner_token ( scanner,
token_type )
related
Value:
&& ((scanner)->current + 1 < (scanner)->table + (scanner)->tokens) \
&& (scanner)->current[1].type == (token_type))
The struct scanner describes the current state of the scanner.
Definition scanner.h:107
#define scanner_has_tokens(scanner)
Definition scanner.h:141

Checks the type of the next token.

◆ check_scanner

#define check_scanner ( scanner)
related
Value:
int tokens
Definition scanner.h:117
struct scanner_token * current
The current token and number of scanned tokens in the table.
Definition scanner.h:116
struct scanner_token table[SCANNER_TOKENS]
The table contain already scanned tokens.
Definition scanner.h:137
#define SCANNER_TOKENS
The number of tokens in the scanners token table: At best it should be big enough to contain properti...
Definition scanner.h:104

This macro checks if the current scanner state is valid.

Meaning if the scanners table is full the last token skipping or get_next_scanner_token() call made it possible to get the type of the next token.

◆ get_next_scanner_token()

struct scanner_token * get_next_scanner_token ( struct scanner * scanner)
related

Do a scanning if we do not have also have access to next token.

◆ get_scanner_token()

struct scanner_token * get_scanner_token ( struct scanner * scanner)
related

Access current and next token.

Getting the next token might cause a rescan so any token pointers that has been stored in a local variable might not be valid after the call.

◆ init_scanner()

void init_scanner ( struct scanner * scanner,
struct scanner_info * scanner_info,
const char * string,
const char * end )
related

Initializes the scanner.

◆ map_scanner_string()

int map_scanner_string ( struct scanner * scanner,
const char * ident,
const char * end,
int base_type )
related

Looks up the string from ident to end to in the scanners string mapping table.

◆ scanner_has_tokens

#define scanner_has_tokens ( scanner)
related
Value:
((scanner)->tokens > 0 && (scanner)->current < (scanner)->table + (scanner)->tokens)

◆ skip_scanner_token

#define skip_scanner_token ( scanner)
related
Value:
static struct scanner_token * get_next_scanner_token(struct scanner *scanner)
Do a scanning if we do not have also have access to next token.
Definition scanner.h:176

This should just make the code more understandable .

. hopefully

◆ skip_scanner_tokens()

struct scanner_token * skip_scanner_tokens ( struct scanner * scanner,
int skipto,
int precedence )
related

Removes tokens from the scanner until it meets a token of the given type.

This token will then also be skipped.

Field Documentation

◆ current

struct scanner_token* scanner::current

The current token and number of scanned tokens in the table.

If the number of scanned tokens is less than SCANNER_TOKENS it is because there are no more tokens in the string.

◆ end

const char * scanner::end

◆ info

struct scanner_info* scanner::info

The 'meta' scanner information.

◆ position

const char * scanner::position

◆ state

int scanner::state

Some state indicator only meaningful to the scanner internals.

◆ string

const char* scanner::string

The very start of the scanned string, the position in the string where to scan next and the end of the string.

If position is NULL it means that no more tokens can be retrieved from the string.

◆ table

struct scanner_token scanner::table[SCANNER_TOKENS]

The table contain already scanned tokens.

It is maintained in order to optimize the scanning a bit and make it possible to look ahead at the next token. You should always use the accessors (defined below) for getting tokens from the scanner.

◆ tokens

int scanner::tokens

The documentation for this struct was generated from the following file: