ELinks 0.18.0
scanner.h File Reference
#include "util/scanner.h"
Include dependency graph for scanner.h:
This graph shows which files directly or indirectly include this file:

Macros

#define skip_css_tokens(scanner, type)
#define get_css_precedence(token_type)

Enumerations

enum  css_token_type {
  CSS_TOKEN_IDENT = 256 , CSS_TOKEN_NUMBER , CSS_TOKEN_PERCENTAGE , CSS_TOKEN_STRING ,
  CSS_TOKEN_ANGLE , CSS_TOKEN_DIMENSION , CSS_TOKEN_EM , CSS_TOKEN_EX ,
  CSS_TOKEN_FREQUENCY , CSS_TOKEN_LENGTH , CSS_TOKEN_TIME , CSS_TOKEN_HASH ,
  CSS_TOKEN_HEX_COLOR , CSS_TOKEN_FUNCTION , CSS_TOKEN_RGB , CSS_TOKEN_URL ,
  CSS_TOKEN_AT_KEYWORD , CSS_TOKEN_AT_CHARSET , CSS_TOKEN_AT_FONT_FACE , CSS_TOKEN_AT_IMPORT ,
  CSS_TOKEN_AT_MEDIA , CSS_TOKEN_AT_PAGE , CSS_TOKEN_IMPORTANT , CSS_TOKEN_SELECT_SPACE_LIST ,
  CSS_TOKEN_SELECT_HYPHEN_LIST , CSS_TOKEN_SELECT_BEGIN , CSS_TOKEN_SELECT_END , CSS_TOKEN_SELECT_CONTAINS ,
  CSS_TOKEN_GARBAGE , CSS_TOKEN_SKIP , CSS_TOKEN_NONE = 0
}
 The various token types and what they contain. More...

Functions

static int check_css_precedence (int type, int skipto)
 Check whether it is safe to skip the type when looking for skipto.

Variables

struct scanner_info css_scanner_info

Macro Definition Documentation

◆ get_css_precedence

#define get_css_precedence ( token_type)
Value:
((token_type) == '}' ? (1 << 10) : \
(token_type) == '{' ? (1 << 9) : \
(token_type) == ';' ? (1 << 8) : \
(token_type) == ')' ? (1 << 7) : 0)

◆ skip_css_tokens

#define skip_css_tokens ( scanner,
type )
Value:
#define get_css_precedence(token_type)
Definition scanner.h:109
const char * type
Definition download.c:1899
The struct scanner describes the current state of the scanner.
Definition scanner.h:107
struct scanner_token * skip_scanner_tokens(struct scanner *scanner, int skipto, int precedence)
Definition scanner.c:37

Enumeration Type Documentation

◆ css_token_type

The various token types and what they contain.

Patterns taken from the flex scanner declarations in the CSS 2 Specification.

Char tokens range from 1 to 255 and have their char value as type meaning non char tokens have values from 256 and up.

* {...} means char group, <...> means token
* {identstart} [a-z_]|{nonascii}
* {ident}   [a-z0-9_-]|{nonascii}
* <ident>   {identstart}{ident}*
* <name> {ident}+
* <number>  [0-9]+|[0-9]*"."[0-9]+
* 
Enumerator
CSS_TOKEN_IDENT 

<ident>

CSS_TOKEN_NUMBER 

<number>

CSS_TOKEN_PERCENTAGE 

<number>%

Percentage is put because although it looks like being composed of <number> and '%' floating point numbers are really not allowed but strtol() will round it down for us ;)

CSS_TOKEN_STRING 

Char sequence delimited by matching ' or ".

CSS_TOKEN_ANGLE 

<number>rad, <number>grad or <number>deg

CSS_TOKEN_DIMENSION 

<number><ident>

CSS_TOKEN_EM 

<number>em

CSS_TOKEN_EX 

<number>ex

CSS_TOKEN_FREQUENCY 

<number>Hz or <number>kHz

CSS_TOKEN_LENGTH 

<number>{px,cm,mm,in,pt,pc}

CSS_TOKEN_TIME 

<number>ms or <number>s

CSS_TOKEN_HASH 

#<name>

XXX: CSS_TOKEN_HASH conflicts with CSS_TOKEN_HEX_COLOR. Generating hex color tokens has precedence and the hash token user have to treat CSS_TOKEN_HASH and CSS_TOKEN_HEX_COLOR alike.

CSS_TOKEN_HEX_COLOR 

#[0-9a-f]\{3,6}

CSS_TOKEN_FUNCTION 

<ident>(<args>)

For all unknown functions we generate on token contain both function name and args so scanning/parsing is easier. Besides we already check for ending ')'.

CSS_TOKEN_RGB 

rgb(

For known functions where we need several args [like rgb()] we want to generate tokens for every arg and arg delimiter ( ',' or ')' ).

CSS_TOKEN_URL 

url(<arg>)

Because url() is a bit triggy: it can contain both <string> and some chars that would other wise make the scanner probably choke we also include the arg in that token. Besides it will make things like 'background' property parsing easier.

CSS_TOKEN_AT_KEYWORD 

@<ident>

CSS_TOKEN_AT_CHARSET 

@charset

CSS_TOKEN_AT_FONT_FACE 

@font-face

CSS_TOKEN_AT_IMPORT 

@import

CSS_TOKEN_AT_MEDIA 

@media

CSS_TOKEN_AT_PAGE 

@page

CSS_TOKEN_IMPORTANT 

!

<whitespace>important

CSS_TOKEN_SELECT_SPACE_LIST 

~=

CSS_TOKEN_SELECT_HYPHEN_LIST 

|=

CSS_TOKEN_SELECT_BEGIN 

^=

CSS_TOKEN_SELECT_END 

$=

CSS_TOKEN_SELECT_CONTAINS 

*=

CSS_TOKEN_GARBAGE 

A special token for unrecognized strings.

CSS_TOKEN_SKIP 

Token type used internally when scanning to signal that the token should not be recorded in the scanners token table.

CSS_TOKEN_NONE 

Another internal token type used both to mark unused tokens in the scanner table as invalid or when scanning to signal that the scanning should end.

Function Documentation

◆ check_css_precedence()

int check_css_precedence ( int type,
int skipto )
inlinestatic

Check whether it is safe to skip the type when looking for skipto.

Variable Documentation

◆ css_scanner_info

struct scanner_info css_scanner_info
extern